My activity with the ESP8266/ESP32 boards had somehow fallen asleep after I set up one of the ESP8266 as Wifi-repeater. It worked, but creating own devices was too cumbersome. Firing up the ArduinoStudio took ages, building and downloading the firmware in C++ was error-prone, took ages (seriously, this is a tiny program, what the hell happens in the background?).
But I knew there exists a path, which could save some time: µPython (micropython). It runs a firmware, you just deploy your “code”. In my case now a tiny hello-world-like program.
I used this and that tutorial and the uPyCraft-IDE. Got it working with an ESP8266 in minutes.
Seriously: goodbye crappy, non-structured and slow-to-build C/C++ for my microcontrollers. The future is here o/
By the way: the motivation also comes from my current daily practice of Python (of course, I still contribute to C++/Qt-based projects), but my current flame is Python (for Project Euler and daily coding challenges).
Three weeks ago, while being in the garden, I noticed that there is no network connectivity except by superslow EDGE. Of course, three walls block the Wifi-router, but what about one repeater which is closer and just shielded by one wall? Also I remembered having read about the usage of some ESP-nodes for that. I don’t like the approach of buying some closed-source-product.
Short research yielded the project from martin-ger on Github, which I wanted to use. I was surprised that nothing for the ESP32 is available (only for ESP8266). So I tracked down my single ESP8266 (LoLin, NodeMCU, not sure which revision, but with CH340G-USB-connect and as DevKit (mingling with pulldown-resitors would add another layer of complexity, which I am not sure I want to tackle).
Turns out I could not flash the given item properly with the ESP8266 Download Tool 3.65. It blinks while doing so, but follow-up seral-monitoring onyl yields “lolin ts Jan 8 2013,rst cause:2, boot mode:(3,6)”.
So I ordered a from a german shop a new ESP8266. Looks like exactly the same model.
Will do some quicktest now with the blink-app (basic functionality and flashing works?). And then do a test with the ESP Download tool.
More later ..
Acquired a Bosch BME280 for improved humidity, air pressure and temperature-measurement (DHT22 can’t read barometric pressure) and tried to attach it via I2C.
Let’s keep it short: the sensor got very hot after several tries to find the correct wiring. Even using the i2c-scanner testprogram did not yield any results. But I learned how to use the breadboard more effectively. The burnt IC will be sold as ‘Lehrgeld’ 😉 (Oh, the days when I fried my AMD Duron, because I thought that a CPU won’t heat up so fast at boot. Boy was I wrong.)
Integrated then at least via analog reading the YL-69 moisture sensor. Worked well and on first try. Guess I just need to read much, much .. more about I2C, wiring and the sensors.
Another lesson learned: if you want to see really badly structured, basic coding: check tutorials for microcontrollers :/ (especially mine ;))
Code is committed and pushed to github.
Output is something like:
Humidity (DHT22): 72.90 % Temperature (DHT22): 24.10 °C
Temperature (internal): 31.11 °C
Moisture (YL-69): 27%
To give my (non-existant) skills for microcontrollers and reading out sensor-values a kick-start, I decided to connect today an DHT11 to the ESP32.
So, at first I realized I have no clue how a breadboard works, then that I need a calculator to determine the resistors properly, then “how to determine the correct pin-numbering”, then … it did not work, no matter what I tried. The C++-code was the least issue. Several sources provide examples, also with webserver (looks like everyone ~stole~ got inspired from each other ..), but the read-out always failed.
Luckily I had two (a bit more ‘expensive) DHT22 at hand and it worked like a charm!
Lessons learned: 0. accept that you know nothing 1. reading and experimenting is fun 2. seeing finally a presentable result is great <3
Humidity: 71.20 % Temperature: 24.40 °C
Temperature (internal): 31.67 C
For an investment of 80-90 minutes time I am quite happy about the result and amazed what sohisticated capabilites are offered at some really easily accessible level.
What has been achieved so far?
* setting up a working Arduino Studio 1.8.5-environment with ESP32-toolchain on a Win7-laptop (not my favorite, but Linux-PC was blocked)
* setting proper options to the IDE to make the examples compile and upload via serial to the board; learn how to use the integrated serial-monitor
* finding the proper PIN-setup for the MAX7219-LED-display (just one module – for now) and setting up the library
* playing around with the WiFi-functionality (scanning for networks)
* putting both tasks (network scan and led-output) together and running into the first “I need threads”-pit
[Video was taken at an early stage: a static string is displayed.]
Of course, THIS is nothing, just the very first tiny baby-step. Everyone is able to achieve this, because almost no creativity needs to be invested.
But: configuring all the necessary tools was already a pain in the ass. Of course, just read the manual(s) [..]
But this is not a “unwrap and press start”-toy, so the learning-curve was steeper than expected.
But I did it. And I look forward. Especially to put some threaded application on the MCU, because – why just run one thread, when you can have two? 😉
Ok, the first drafts of the ESP32 (successor of the ESP8266) as presoldered boards (mostly called development-board) appeared 2016, so acquiring something like this in the current year is nothing special. BUT: I’ve had my hands on an ESP8266-board (nodeMCU v3 – if I remember correctly) and I was astonished! Integrated wifi on such a tiny board and then even micro-USB for flashing, wow. For someone who played with the MSP430-chips from Texas Instruments for his bachelor thesis, this is finally something affordable. “Smaller” than the RPi, but I see alot of potential for gathering and preparing data and the final distribution of information.
So, today I ordered from China (why buy from local or european shops, when you can save 60% if you have time?):
- 2 x ESP32S (240 MHz DualCore from Tensilica, 4 MiByte integrated flash memory, Wifi, Bluetooth)
- 2 x DHT22 temperature and humidity-sensor
- 2 x MAX7219 modules (8×8 LED)
- 2 x MAX7219 modules with 4 blocks in line (32×8 if you want to call it that way)
- 2 x 0.96″ OLED displays RGB(!) and 128×64 pixel
Alltogether for less than 40 €, which is really crazy. Let us hope everything arrives well and in the next five weeks and then the tinkering can start 🙂 Have two “weather sensor-stations” in mind. Maybe a Raspberry as sink for the data. Maybe some Android-app via Blynk. Let us see…
I have the skill(s) – give me the hardware! 🙂