Wemos LOLIN32: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
Zeile 56: Zeile 56:
 
  GND
 
  GND
  
Now you can measure the voltage on the battery using the ADC. As the ADC is 12bit, you can get the actual voltage by multiplying the reading by ((27+100)/100) * 3.3 / 2**12
+
Now you can measure the voltage on the battery using the ADC. As the ADC is 12bit, you can get the actual voltage by multiplying the reading by ((27+100)/100) * 3.3 / 2**12, or in more general terms: ((R1 + R2) * V_ref) / (R2 * 2**Resolution).
  
 
== Example Projects ==
 
== Example Projects ==
  
 
* Temperature and Humidity measurement using collectd as datalogger: [https://github.com/reox/esp32_sht21_collectd ESP32_SHT21_collectd]
 
* Temperature and Humidity measurement using collectd as datalogger: [https://github.com/reox/esp32_sht21_collectd ESP32_SHT21_collectd]

Version vom 15. Januar 2018, 10:01 Uhr

The Wemos LOLIN32 is a ESP-WROOM-32 based IoT development board. It is available in the [1].

As the original page has no documentation at all, here are some findings about the hardware.

Flash Micropython

The Version for ESP32 works: http://micropython.org/download#esp32 Currently (as of 08-08-2018) there is no RTC support in the ESP32 branch! That means, you are also not able to set the time correctly. My super nasty hack is, to use NTP every time you need the time...

Beware: use esptool >= 2.2! I tried with esptool 2.0 first and got an endless boot loop.

Flash the image like this:

wget http://micropython.org/resources/firmware/esp32-20180108-v1.9.3-238-g42c4dd09.bin  # Adjust downloadlink!
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180108-v1.9.3-238-g42c4dd09.bin  # Adjust image Name

Upload Files

You can use ampy to upload files. WebREPL should also work, but it looks like this code is also missing in the current ESP32 branch of Micropython.

ampy is very straight forward.:

ampy --port /dev/ttyUSB0 put main.py

I2C

The board has dedicated I2C Pins, but it does not look like a hardware implementation?! In Micropython you need to define either a hardware address or the Pins. I could not find any information about the hardware address of the I2C chip. Therefore I initialized I2C like this:

import machine
i2c = machine.I2C(sda=machine.Pin(21), scl=machine.Pin(22), freq=400000)

# Now scan the bus:
i2c.scan()

Battery Monitoring

Unfortunately, no direct method of battery voltage measurement is built into the system. But it should be quite easy to implement such a thing: Use a voltage divider on the battery to get a 3.3V max. For a 4.2V cell, this can be achieved using a 27k and 100k resistor.

 ^  V_bat
 |
 R1 = 27k
 |
 +----o ADC
 |
 R2 = 100k
 |
GND

Now you can measure the voltage on the battery using the ADC. As the ADC is 12bit, you can get the actual voltage by multiplying the reading by ((27+100)/100) * 3.3 / 2**12, or in more general terms: ((R1 + R2) * V_ref) / (R2 * 2**Resolution).

Example Projects