I've decided I need to do something vaguely useful with a few microcontroller boards I have, use some of the simple ESP8266 ones to collect temperature and humidity data from various rooms of the house to a MQTT server, collect that data in a RRD and show the current values on an epaper panel together with the current time and weather forecast.
Current status is:
* the MQTT server at home is no longer working (uops, that's why I wasn't receiving other unrelated notifications. I believe I know what the reason is, and how to solve it, but not today. I have mosquitto installed also on the laptop and that one is working)
* the python library I wanted to use to read data from MQTT is broken in debian testing (bug opened at the end of november)
* I can't find the ESP8266 boards. I know that they are around here somewhere, but WHERE???
diorama ١٣١٢ (demm/ihn) reshared this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •on the plus side, I now have a not exactly adequate ESP32 board (ESP32-CAM from @Olimex, the -CAM bit is the reason why it isn't the right board for this :D ) that is currently going into deep sleep, waking up every almost-5 minutes and sending a message over MQTT that tells me that there are 18°C (hardcoded :D ).
I wonder if I should change it to 20°C to make it feel warmer :D
or rather, tomorrow I'll try to attach a DHT22 and fill in realistic values :D
hopefully the same #arduino code will work on the ESP8266 boards when I'll find them.
Olimex reshared this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •The DHT22 can't be read.
Possible causes:
* the DHT22 is dead
* I'm not powering it enough
* The ESP32 is not able to bitbang the DHT22 protocol
I think I'll stop here and resume the attempts later.
If I find the boards I originally wanted to use I can try to test the power issues (here I was using an unholy maze of jumper cables).
I may have planned to buy a DHT20 in the future (probably after the christmas holidays, however, and for sure after this weekend), so if it's an issue with bitbanging the DHT22 protocol that will get a different solution.
And I may try to connect the DHT22 to some other board to check whether it's still alive, but probably not today.
#microcontrollers
Damiano Verzulli
in reply to Elena ``of Valhalla'' • • •:
say that it operates within a 3.3V-6V . How are you powering it?👉 "the DHT22 is dead": very unlikely, unless you "burned" it... Did you?
👉 "I'm not powering it enough": the datasheed
👉 "The ESP32 is not able to bitbang the DHT22 protocol" : there should be battle-tested libraries dealing with the DHT22. Which one are you using?
-----
sparkfun.com/datasheets/Sensor…Elena ``of Valhalla''
in reply to Damiano Verzulli • •@Damiano Verzulli
* the DHT22 has been in a drawer for years: I don't think I would have put it back in the drawer if it had been burned, but who knows
* as I said, I'm powering it through an unholy ratnest of jumper cables. it should provide 5V, but an earlier attempt at powering it at 3.3V with a bit less of a ratnest only provided 2.something V, and with the 5V I didn't have room to actually measure it without breaking the ratnest and disconnecting everything (yes, I tried).
This is caused by the way the board I'm using is being powered (through the programmer, on the single available 5V pin), and since I'm not planning to use this specific board anyway I've decided it's not worth spending any more time.
* I'm using the library from Adafruit, it was their documentation that recommended¹ trying things with an arduino uno first, as on some boards it didn't work (but it didn't have a list of working boards, or at least it wasn't directly linked).
¹ following recommendations? from the documentation? NEVER :D the documentation is only skimmed to find the syntax to use :D
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •Last week we might have received a few ESP32-C3-DevKit-Lipo, yesterday I promptly managed to semi-brick one of them while programming them via arduino.
To avoid that semibricking, the right board to use is ESP32C3 Dev Module, AND you need to enable USB CDC On Boot
And to avoid panicking, bringing GPIO9 to GND will set the board into bootloader mode :D
rag. Gustavino Bevilacqua reshared this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •Then, with the board nicely sitting on a breadboard, a stable 3.3V and no ratnest of jumper cables I've seen that the code I wrote last week works: the board turns on, connects and sends the temperature and humidity data from the DHT22 on mqtt, sets a timer and goes into deep sleep.
As long as you don't use Serial.flush(); before going into deep sleep, otherwise it will hang on it until it *gets* a serial, or something, and it will not have a serial while running on battery (uooops).
(yes, the DHT22 seems to be working fine on 3.3V, probably as long as it's close enough to the board that the voltage isn't dropping. and I'm not going to have 5V while on battery, so 3.3V it is)
rag. Gustavino Bevilacqua reshared this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •The Bag of Random Sensors that had the DHT22 also gifted me with 3 (THREE!) BMP280 (temperature and atmospheric pressure, I2C or SPI).
While playing with them I've learned:
* The #esp32c3 can use #i2c on any pin; the default I believe is 8 and 9, but they are also used while programming, so meh
* You can change the i2c pins in #arduino by calling Wire.setPins(I2C_SDA, I2C_SCL); before any Wire.begin();
* There is an example sketch called Wire -> WireScan which scans for i2c devices (you will have to change it to use the pins you want to use with a call to Wire.setPins) which is a godsend.
reshared this
rag. Gustavino Bevilacqua reshared this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •aaaand, temperature and pressure have been read.
for some reason, however, right now arduino isn't compiling the sketch twice in a row (with the error “panic: runtime error: index out of range [9] with length 9”).
But I'll look into it probably during the Christmas holidays, for today I'm ok with this.
Elena ``of Valhalla''
in reply to Elena ``of Valhalla'' • •oh, right. I was supposed to look into the arduino failures.
instead, I've looked a bit at the python side of things, and surprisingly what I did worked fine, even if it wasn't much.
Larry (Mr. Prototype)
in reply to Elena ``of Valhalla'' • • •The whole ESP32 family can do hardware I2C on most of their bidirectional GPIO pins. I2C is a relatively simple protocol that can be simulated in software on any GPIO pin on any MCU (FYI):
github.com/bitbank2/BitBang_I2…
GitHub - bitbank2/BitBang_I2C: A software I2C implementation to run on any GPIO pins on any system
GitHubElena ``of Valhalla'' likes this.