As part of one of my pushes to get more involved in the physical world and out of the digital world I’ve been experimenting with electronics, in particular, the ESP32 microcontroller as well as an Arduino.
There’s something I’ve found about interacting with a physical piece of kit in front of me, something that I can manipulating and touch with my hands, that I just haven’t been able to get with pure software projects in the past. It’s been a blast so far and I mean that genuinely, not in the fake internet way where everything is awesome or epic. I feel engaged and interested in learning about something and seeing the results. It’s just plain fun and interesting at the same time and it’s going to be interesting to see where this develops.
The first two projects that I’ve been working on have been:
- ESP32 Web Server with a DHT22 Temperature Sensor
- Arduino Uno “Garduino” with a capacitative soil moisture sensor and the same DHT22 probe
So far, I’ve learnt a ton and made a number of mistakes.
For technology, I’ve been using a genuine Arduino Uno and a DFRobot Firebeetle ESP32 dev board to get started. The Arduino I’ve found has been really awesome for just trying something really quickly. They’re pretty big though, especially compared to the Firebeetle as well. This isn’t hugely important at this stage but it may become a factor later on. Of potentially more impact, the ESP32 has WiFi and can be used to send data.
An Arduino uno side by side with the DFRobot Firebeetle ESP32
My current plans are to use a basic temperature sensor project and the Garduino as learning projects. In these, I’m not going for low cost or for the prettiest design. Instead I’m treating it as incremental steps to get going with the project as a whole.
So far I’ve been able to get the temperature sensor working on the ESP32. Things I learnt:
- Baud Rate (symbol rate) must be matched between the ESP32 and the Serial Monitor, if the baud rate is off then you’ll just get gibberish. The baud rate relates to the symbols per second that are being transmitted over the sensor. If these are different between the sender (ESP32) and the receiver (Computer) then you won’t be able to interpret it.
- Pin Numbers - The Digital Pins on the Firebeetle ESP32 (unlike on the Arduino) are not mapped. Digital Pin “4” in this case maps to GPIO pin 27. Thus, you need to define the pin as 27 in the code. This took me way too long to figure out.
- Installing Libraries - Had to install a few C libraries into the Arduino IDE in order to use them. I don’t fully understand how this works but I know I’ll get better over time.
- Updating Python Version in the Arduino IDE - This was defaulting to Python2 which was breaking in a myriad of different ways. I managed to get around it by setting a symlink to “python” to “python3” of course, this has probably broken my system in a number of other ways.
- Breaking in a breadboard - The new breadboard when I got it wasn’t as “soft” as the one I got with the Arduino. Once I’d “pushed it in” a few times with male header pins it was working a lot better.
- Better at breadboarding - My prototyped circuits are beginning to look a bit more elegant as I get used to the
I’ve also gone down a few rabbit holes that were probably not necessary at this stage. This includes:
- Researching different battery chemistries - One of my original ideas was to have battery powered ESP32 servers floating around the house. This is still a “maybe” on the agenda. It’s a bit of a tricky one as it opens me up to a lot of complexity.
- Researching home automation - Once again, trying to run before I can walk. Goal is to walk
- Looking at 3D printers - Will need enclosures, running before walking
- Looking at bulk orders - Do I really need 50 ESP32 modules to get a slight discount?
Next Steps
Now that I’ve got some of the basics working I need to get the following working:
- ESP32 Temperature Sensor able to send JSON (or equivalent) to a server
- Set up a server to receive the ESP32 data (local or cloud? Do I trust someone else with my data?)
- Power the ESP32 from a power supply rather than off my computer to break the chain and be able to place it where I want it.
- I did look into battery power, little bit nervous about using LiPo batteries though, especially in Australia as it gets pretty hot here
- Learn how to solder
- Need to pick up a soldering iron as well as a soldering kit.
- Solder the temperature sensor design together so I can move past the breadboard
- Create an enclosure for it so that it looks a bit more attractive
- Output the data to some form of persistent dashboard
- Looking at setting up Home Assistant for this
- Create multiple sensors and have everything working together
Other assorted things I’ve learnt
- I need a bigger desk
- I need a way to organise components in a clean fashion
- This is definitely going to be an absolute money pit
Bonus: Garduino
The basic Garduino that I was able to get going used:
- An Arduino Uno
- The DFRobot Capacitative Soil Moisture Sensor - SEN0193
- A DHT22 Temperature and Humidity Sensor (AM2302)
I was able to wire all of this together as follows:
And then run this pretty basic code:
#include <DHT_U.h>
#include <DHT.h>
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
const int AirValue = 520; // My Calibrated Air Value
const int WaterValue = 294; //Value when placed in a glass of water
int soilMoistureValue = 0;
int soilmoisturepercent = 0;
void setup() {
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
dht.begin();
}
void loop() {
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
float heat_index = dht.computeHeatIndex(temperature, humidity, false);
Serial.print("The Soil is: ");
Serial.print(soilmoisturepercent);
Serial.print("% Moist, Sensor Reading: ");
Serial.print(soilMoistureValue);
Serial.print(", Air Temperature is: ");
Serial.print(temperature);
Serial.print(", Air Humidity is: ");
Serial.print(humidity);
Serial.print(", Heat Index: ");
Serial.println(heat_index);
delay(4000);
}
Which gives me the following lovely output:
It ain’t super pretty in any way but most importantly it works. Lots to do and more to build on top of I think. That wraps up this post, excited to see what comes next.