Project 36: |
v6.0 ESP32 (DOIT DevKit-C v4): Schematic, Board Layout, PCB Top and Bottom
Demo of Prototypes SH110x and ST7789 Displays The v6.0 PCBs will be sent out for fab once the breadboard proves out.
Overview: ESP32 development unit hosts a WiFi web server to share temperature, humidity and barometric pressure. They can be placed in various locations and accessed via a web page. Additionally, WiFi MAC address and IP address are displayed. v6.0: DOIT ESP32 DevKit-C v4 with AliExpress_2.0" Colour IPS_Display or 1.3" OLED
Arduino Code: v4.1 ESP32 with ST7789_2.0"_Colour_IPS_TFT_or_SH1106 1.3" OLED display and BME280 sensor v6.0 BME280_OLED_RGB_SNTP_SD.ino Note: If your ESP32 ever locks up, try this code: Reset_ESP32.ino |
HOW DOES IT ALL WORK? We have designed a PCB to accommodate a number of devices. If you wish to learn how things work while assembling the PCB then I suggest you get yourself a quality breadboard, jumper wires and follow the directions below. The PCB will contain the
following: We'll start off by testing
the I2C Devices: If you install two rows of 19-pin sockets (or a
single
38-pin double socket
or cheaper
40-pin double socket) for each side of the ESP32, you can
connect it via the spare pin sockets to a breadboard: the 38-pin
ESP32 is too wide to be used on a standard breadboard. SCL on the ESP32 is pin 22 and SDA is pin 21. If the two I2C devices you're using are designed "properly", they already contain pullup resistors on SCL and SDA. All of these type of sensors I have looked at had SMT resistors marked as 103 indicating they were 10k. They also had a 100nF noise coupling cap on the power supply pin.
Let's start by checking the I2C address of the
OLED using the Serial Monitor and the scanner sketch
I2C_Scan.ino Remove the BME280 sensor and install the AHT10 sensor. Run the scanner sketch again. - AHT10 I2C address is 0x38 If you install all 3 devices, you should be able to see them all listed in the Serial Monitor as shown here. If one of the devices tested separately is not showing up, consider changing to one of the alternative I2C addresses. For the BME280 that could be 0x76 instead of 0x77. I2C is now tested.
OLED is now tested.
Remove the OLED, install the BME280 sensor, load and run the sketch, BME280_Test.ino. Results can be seen in the serial monitor and here.
Remove the BME280, install the AHT10 sensor,
load and run the sketch,
AHT10_Test.ino. Results can be seen in the serial monitor
and here. Your sensors are now tested.
We have separately tested the OLED display and
the BME280 or AHT10 sensors, so now let's test them at the same
time. Load up and run the sketch
BME280_OLED.ino
An example from the Serial Monitor can be found here.
The RGB LED is now tested. Now that it has stabilized close RGB.ino, upload and run OLED_BME_RGB.ino again. Make sure SM is running before you start the upload to the ESP32.
OLED_BME_RGB_Time.ino is our next sketch.
Here is an example
of it working on the Serial Monitor. - The next function EthIP displays both the WiFi MAC and IP addresses on both the OLED and SM - In the next function, RGBLEDs_Off(), the three RGB LEDs are turned off. - In the final function, RGBLEDs_OnOff(), the three LED colours are cycled on and off The local Time function is now tested.
BME280_OLED_RGB_SNTP.ino contains all of the previous code. Code has been added so that the network time protocol (SNTP protocol) is used to accurately update the current time. Here is an example of it working on the Serial Monitor. The following lines were added: - 29 to 32: drivers, time zone and daylight savings time offset - 95 to 100: Can get IP address from DHCP server or the others configured in configTime(). When current time is updated via SNTP, another function timeavailable() can run. It is found in lines 221 to 223. ConfigTime() specifies offset from UTC/GMT, daylight savings time, and two NTP time servers. Lines 36 and 99 accomplish the same thing - 105: function netTimeOLED() of lines 208 to 219 is called which displays the time in the Serial Monitor and on the OLED after clearing it The SNTP network time function is now tested.
BME280_OLED_RGB_SNTP_SD.ino contains additional SD drive code. You MUST use the ESP32 SD and FS drivers or expect trouble during compilation. The driver set can be found here: https://github.com/espressif/arduino-esp32 Info on installing the Arduino-ESP32 support files is found here: NOTE: You may already have SD and FS libraries on your PC located in: 1) C:\Program Files (x86)\Arduino\libraries 2) C:\Users\Your_Name\AppData\Local\Arduino15\libraries 3) C:\Users\Your_Name\Documents\Arduino\libraries Personally, I moved them to private folders, zipped them up and moved them away from the Arduino IDE. This way only the ESP32 drivers will be used.
Some of the code related to displaying the date and time has been cleaned up so the line numbers in BME280_OLED_RGB_SNTP_SD.ino won't be the same as our earlier file, BME280_OLED_RGB_SNTP.ino .
Code changes for the SD drive are listed below: - Lines 22 to 25 define the SD drivers and file system drivers needed to run the micro SD card drive - Lines 106 to 115 start the SD drive with the ESP32 DevKit-C v4 specific pins - Lines 290 to 304 contains a list of the File System calls for the SD drive. The calls or functions follow. - In loop() most of the code is the same but line 258 contains the data as a numerical string, e.g., 2024.09.07,16:01:02. This will make it easier to log the temperature/humidity/BP on the SD drive
String Formatting (BME280_OLED_RGB_SNTP_SD.ino ) This was the first time I have worked with formatting time to be used as a string that could be written as a line of data to an SD drive. The line numbers involved in the procedure start with line 215 in the function Line5SD(). I used http://gemini.google.com/app to get hints on how to manipulate time data to a character string. I listed the two web links on line 225. The comments that follow the code should hopefully be helpful. Here is an example of it working on the Serial Monitor. The micro SD drive is now tested. |
Updated 2024-09-11 @ 8am