E-Bike Energy Consumption

Anticipating a lot of spare time and with rare good foresight, I bought an electric bicycle at the beginning of the COVID19 lockdown. I wanted a folding model so that it could be put into the car trunk and big wheels because the small-wheel folding bikes look strange to me. The Ancheer 26-inch folding mountain bike fit these specifications and was delivered in just a week. My timing was good because orders a few weeks later took up to two months to arrive.

Putting it together was fun and took less than two hours despite the cryptic instruction printed in a microscopic font. Everything was included though the assembly tools are best described as “disposable”. The brakes and derailleurs were properly adjusted from the factory. The hardest part was waiting 24-hours to charge the battery as instructed. This is important as the life of lithium polymer batteries is extended when the cells are leveled with a long initial charge.

There is a very active and well run support group for all Ancheer electric bikes on Facebook at https://www.facebook.com/groups/621212528377039.

The Ancheer 26-inch folding bike is powered by a 250-watt brushless hub motor on the rear axle and an 8 ampere-hour, 36-Volt lithium polymer battery. It has front and rear mechanical disc brakes and a 21-gear derailleur. Despite the aluminum frame it weighs 65 pounds (30 kg).

Riding an e-bike is exhilarating. Acceleration and hill-climbing are effortless and if you tire yourself with pedaling you can recover while cruising on electric power.

There are three modes of use: 1) pedal assist, 2) manual throttle, and 3) regular unassisted bike riding. In pedal-assist mode, a cadence sensor on the pedal crank signals the controller when you are pedaling and supplements your effort with motor power. Some e-bikes have up to nine levels of pedal assist, the Ancheer has three. At the lowest level, the assist is barely noticeable but helpful. The mid-level assist is a good compromise. The high level runs the bike to a higher speed than I can pedal.

I prefer the manual throttle mode. There is a twist control on the right handlebar that lets you control exactly how much power the electric motor will deliver. I especially like the throttle mode when crossing a busy street from a standstill as it will accelerate the bike very quickly when also pedaling.

Soon after I got my Ancheer 26-inch folding electric bicycle, I built the data logger described in another post: https://w4krl.com/e-bike-logger/ The logger directly measures battery voltage and current, and calculates wattage. It also records calculated energy consumption in terms of ampere-hours and watt-hours. It writes this data to a microSD card every second. The datafile can be opened in a spreadsheet application like Excel to analyze and graph the data.

I plan to make five runs over the same 9.7-mile (15.7 km) round trip course that is mostly paved trails and bike lanes with a short length of hard-packed unpaved trail. Most of the ride is uninterrupted though there are four street crossings that can introduce random delays. The course is relatively flat with a rise of 147 feet and fall of 141 feet.

  • Trip 1: All electric – the run was made mostly at full throttle with minimal human pedaling.
  • Trip 2: Low pedal-assist – to be done
  • Trip 3: Medium pedal-assist – the bike controller was set at the mid pedal assist setting.
  • Trip 4: High pedal-assist – to be done
  • Trip 5: Manual throttle – this run will be made mostly by pedaling with some manual throttle assist. This is my usual riding style.

So far I have made the All Electric Trip 1 and the Medium pedal assist Trip 3 with some interesting comparisons:

  1. Although the bike motor is rated at 250-watts, peak power is actually 400 watts. It appears that the controller limits battery current to 10 amperes.
  2. In the All-Electric mode, the bike uses 0.35 Ah per mile (0.22 Ah/km). If the battery has a true capacity of 8 Ah the range would be 22.8 miles (37 km). This agrees well with rides I made before having the logger. The average speed was 13.2 mph (21.4 km/h). Top speed with electric power only on level paved road is about 20 mph (32 km/h).
  3. The PAS Medium setting reduces energy consumption to 0.20 Ah/mi (0.12 Ah/km). This extends the range by nearly 70% to 38 miles (62 km). [Your mileage may vary!] However, average speed dropped to 11.4 mph (18.5 km/h). I also noticed that there was NO motor assist above 15 mph (24.3 km/h).
  4. Although PAS Medium limited assist to speeds below 15 mph, there was no limit on the peak power of 400 watts.

I will conduct Trips 2, 5, and 5 as time and weather permit. My expectation is that the main difference between the three pedal assist levels is top speed. This is 15 mph for PAS Medium and will probably be full speed for PAS High and a lower speed for PAS Low. It will be interesting to see how the range is affected.

Trip 1Trip 2Trip 3Trip 4Trip 5
ModeAll ElectricPAS
Low
PAS MediumPAS
High
Manual Throttle
Date8/8/2020 8/14/2020  
Data File (csv)Bike8 Bike11  
Distance mi9.7 9.7  
Time2640 3053  
Speed mph13.2 11.4  
Amp-hours3.43 1.96  
Watt-hours128.9 76.5  
Amp avg4.68 2.31  
Watt avg175.8 90.2  
Ah/mi0.35 0.20  
Wh/mi13.3 7.9  
Range ratio1 1.68  
Check back for updates

E-Bike Logger

Soon after I got my Ancheer 26-inch folding electric bicycle, I built a data logger that directly measures battery voltage and current, and calculates wattage. It also records calculated energy consumption in terms of ampere-hours and watt-hours. It records this data on a microSD card every second. The datafile can be opened in a spreadsheet application like Excel to analyze and graph the data.

The prototype hardware used Dupont jumpers to connect the components temporarily housed in a dollar store kitchen container. This worked well on several rides so the next step was to build it on a stripboard and put it in a real project enclosure. The project has gone through several evolutionary improvements and is now well developed.

The project is based on an ESP32 dev kit, specifically the TTGO T8 V1.7 with onboard LiPo charger and microSD card socket. Other ESP32 boards could be used but few are available with the integrated microSD socket. Stand-alone sockets are available that can easily be connected to the ESP32.

E-bike battery current is measured with an ACS712 Hall-effect sensor rated at 20 amperes. Battery voltage is measured with one of the built-in analog to digital converters provided in the ESP32 and scaled with a simple voltage divider. Measured and calculated values are displayed on an LCD1602 backlit display and simultaneously logged to the SD card. At the end of your ride, you remove the card and plug it into a PC to read the comma-separated value (CSV) data. Future development will do the logging on a smartphone allowing the data to be combined with GPS tracking and video recording.

The data is timestamped with two numbers. One number is simply the time in seconds since the start of the log. The other number is the year, month, date, hour, minute, and second obtained from a network time protocol (NTP) source provided Wi-Fi is available when you turn the device on.

A key component is the dc-dc switch-mode converter that supplies 5 V from the e-bike battery. It is difficult to find one that will accept an input voltage of greater than the 42 volts of the open-circuit 36-V battery. I used one rated at 10-Amps that is overkill for the 300 mA needed by the ESP32 but provides plenty of power for a cell phone charger port. It is based on the LT3800 synchronous step down controller. The device is well characterized at https://lygte-info.dk/review/Converter%20DC-DC%2010A%206.5-60V%20to%201.25-30V%20UK.html. There are now sealed modules made for automotive applications that are smaller and less expensive.

The ESP32 has built-in touch sensors. I connected one to the body of the SPDT switch. Touching the switch handle for a fraction of a second changes the display. There are four display screens:

  1. The default dashboard display shows voltage, current, watts, amp-hours, and watt-hours.
  2. A bar graph of the battery current from 0 to 16 Amps.Each block is a 1-ampere division. Each block is subdivided into five columns each representing 200 mA.
  3. A bar graph of battery wattage from 0 to 400 watts. Each block is a 25-watt division. Each block is subdivided into five columns each representing 5 watts.
  4. The clock display shows the current time using a 24-hour format and the hours:minutes:seconds since the beginning of the log.

The code and schematic for the project are on GitHub at https://github.com/W4KRL/EBikeLogger.

Here are some important details:

The software is written in the Arduino dialect of C++. You may install the latest version of the Arduino IDE from https://www.arduino.cc/en/Main/Software. Select the correct version for your computer. Do not use the Web version.

Install the ESP32 core with the instructions at https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/

Add these libraries using the Arduino IDE:

Add your WiFi SSID and password at the places indicated (approximately lines 40 and 41). Add your timezone using the Olson format at line 42. Use this reference https://gist.github.com/ykessler/3349954

Save the file and upload it to the ESP32.

PARTS LIST

ESP32 Analog To Digital Conversion Accuracy

The ESP32 is a powerful microcontroller with many input/output ports. Specifically, it contains two 12-bit multiplexed analog to digital converters (ADCs) for a total of 18 channels. ADC1 is attached to eight GPIOs from 32 to 39. ADC2 is attached to 10 GPIOs (0, 2, 4, 12 to 15 and 25 to 27). There are some restrictions on the use of ADC2 when the WiFi transceiver is active. Since most applications are WiFi-enabled, it is best to use ADC1 when possible.

The 12-bit resolution of the ADC maps the input voltage from 0 to 3.3 Vdc to byte values of 0 to 4,095. Unfortunately, the ADC converters exhibit non-linear characteristics. There is a lower threshold voltage of about 0.13 volts before the ADC starts to register and the volts per bit ratio above about 2.5 volts deviates from the nearly linear ratio between these two regions.

Some careful measurements on a doit.com DevKit v1 obtained the results in Table 1. Figure 1 clearly shows the non-linearities at the lower and upper ends of the input voltage.

By inspection, the ADC has better than 3% accuracy on the input range of 0.14 to 2.6 volts corresponding to ADC output byte values of 100 to 3000. Between 0.21 and 2.53 V the accuracy is better than 1%. Fitting a linear equation to the 1% range produces this relationship:

Vin = 0.0008 * byte + 0.1372 (volts)

Figure 2 shows the entire characteristic of the ADC when compared with the fitted curve. It is clear that the ADC is not usable below 0.13 volts and inaccurate above 2.5 volts.

The next step is to fit another equation to ADC values above 3000:

Vin = 0.0005 * byte + 1.0874 (volts)

Figure 3 shows that these two “piecewise linear” equations produce better than 1% accuracy from 0.14 volts to 3.1 volts.

Code to implement this is easy:

const int PIN_VBAT = 34;
float volts = 0;
int adc = 0;
adc = analogRead( PIN_VBAT );
if ( adc > 3000 )
{
volts = 0.0005 * adc + 1.0874;
}
else
{
volts = 0.0008 * adc + 0.1372;
}

As a practical matter, it is wise to filter the ADC output to remove noise and jitter. There are some nice Arduino libraries to do this but it is quite straightforward to just sum a bunch of readings and take an average. Here is the complete code with the two fitted equations, filtering, and scaling described below:

Scaling

If you want to measure an input voltage above the natural 3 volt range of the ADC you must add a resistor voltage divider to the ESP32 ADC input. You can find formulas to do this on the Internet but there is an excellent online calculator at http://jansson.us/resistors.html. Here are steps to designing a divider for a 50-volt input:

  1. Navigate to http://jansson.us/resistors.html.
  2. Select the resistor series. Resistors in the E12 series are the cheapest and most available.
  3. Find the calculator for “Resistor Ratio” and select the Voltage Divider radio button.
  4. For the maximum input voltage enter 50 for VH.
  5. For the maximum output voltage enter 3.11 for VL. This seems to be the maximum input voltage for the ESP32 corresponding to ADC output of 4,095.
  6. Press the Calculate button. The result is a resistor ratio of 15.077170418006432 to 1.
  7. The calculator provides three possible solutions:
    a. Single: a 150 kΩ in series with 10 kΩ. This is a ratio of 15:1 which is within 0.51% of the desired ratio.
    b. Series: a 300 kΩ resistor in series with the series combination of 18 kΩ and 3.9 kΩ. This is within 0.06 % of the desired ratio.
    c. Parallel: a 120 kΩ resistor in series with the parallel combination of 10 kΩ and 39 kΩ. This is an exact solution.
  8. Add a line to the code to change the scale of the voltage (note that 50.0 is the VH value and 3.11 is the VL value as used in the Resistor Ratio calculator):
    volts = 50.0 * volts / 3.11;
Screenshot from jansson.us/resistors.html

Any of the three voltage divider circuits shown in Figure 4 can be used depending upon the resistor values that are available to you.

Figure 4 – Voltage Divider Circuits

Zambretti Forecaster

The Zambretti Forecaster is a weather forecasting tool in the form of a circular slide rule introduced in 1920.  It claims to accurately predict near-term weather based on barometric pressure, the trend in the pressure (rising, steady, or falling), and wind direction. It relies on the fundamental meteorology of pressure fronts. Watch any TV weather forecast and you will see high- and low-pressure areas prominently displayed on the map. The boundaries between pressure areas are strongly associated with wind and precipitation. Additionally, high-pressure is usually associated with fair weather while low-pressure is associated with cloudy, rainy, or snowy weather.

The are many interesting things about the Zambretti Forecaster. First, there was no Mr. or Ms. Zambretti, rather, it was a trade name used by Negretti and Zambra, a famous London instrument-making company from the mid-19th Century through 1999. Second, there was a modern reproduction on sale in the mid-aughts of the 21st Century though it does not appear to be currently available.

Kevin Scott, Ph. D. has reverse-engineered the modern reproduction in very fine work reported at http://integritext.net/DrKFS/zambretti.htm. He derived an algorithm that is easily implemented in computer code.

Since the D1M-WX1 weather stations accurately monitor barometric pressure, it is easy to apply the Zambretti Forecaster technique to a ThingSpeak channel. My adaptation of Dr.  Scott’s algorithm is provided below as a snippet for a MatLab visualization. To see this in action, open https://thingspeak.com/channels/286120. The Zambretti Forecast is at the bottom of the Current Values display.

Next steps:

  1.  Consider including the rate of barometric change in the forecast.
  2. Track the Zambretti Forecast against weather service predictions.
  3. Publish a pdf with instructions for making your own Zambretti Forecaster.

MATLAB code snippet:

Sending APRS Analog Telemetry – The basics

The amateur radio Automatic Packet Reporting System (APRS) is typically used for position and weather reporting. It can also handle eight digital and five analog telemetry channels. The IoT Kits© solar-powered weather stations have four APRS analog telemetry channels for LiPo cell voltage, time awake, WiFi signal strength, and light intensity. Four digital channels are used for warning alarms: low cell voltage, low signal strength, and sensor failures.

Analog telemetry is transmitted as an 8-bit word, therefore, the analog signal must be mapped to a range of 0 to 255. A good example is the mapping of LiPo cell voltage. An obvious mapping strategy would be to map voltage from 0 to, say, to 5 Vdc. This would quantize the results in steps of about  20 mV (5 V / 255) but it is unnecessary to report voltages below about 3 V because the D1 Mini will stop working.  If we map the range of 2.5 V to 5 V we will cut the quantization step in half to 10 mV, twice the precision of the first approach.  The weather station measures the cell voltage, subtracts 2.5 and divides the result by 10 mV. Say the cell voltage is 4.2, the mapped value is (4.2 – 2.5) ÷ 0.010 = 170.

The telemetry receiver must reverse this process by multiplying the received byte value by 0.010 and adding 2.5 like this: (170 × 0.010) + 2.5 = 4.2 Volts.

How does the receiver know that it must perform this operation to interpret the voltage? Two approaches are possible: we can send the telemetry “blind” since WE know how to interpret it, or we can send instructions so that anyone can understand our telemetry. The IoT Kits weather stations use the second method by sending instructions every two hours so that APRS services such as aprs.fi can correctly plot our data.

It actually takes four messages to completely define the analog telemetry:

T – T is the APRS symbol for telemetry. It is followed by a three-digit sequence number. Earlier versions of the D1M-WX1 weather stations sent a sequence number from 000 to 999 derived from UNIX time obtained fron an NTP server. Current versions send a number from 000 to 255 stored in the ESP8266 RTC memory and incremented on each wake cycle.

PARM – Defines the name of the parameter. APRS limits the name to three to six characters depending on the particular channel. The weather station transmits Vcell, RSSI, Light, and time awake.

UNIT – Defines the units for each channel with the name limited to 3 to 6 characters:  Vdc, dBm, lux, sec.

EQNS – Each analog channel has a quadratic equation that tells listeners how to interpret the 8-bit value associated with each channel.

A quadratic equation is a polynomial of the second order. That means that it is a polynomial function in one or more variables in which the highest-degree term is of the second degree. APRS uses this quadratic equation to interpret the received telemetry data: a · x2 + b · x + c where x is the received byte value.

The EQNS message transmits a set of three coefficients for each analog channel: a, b, and c

For the Vcell channel, the EQNS message looks like this: 0, 0.01, 2.5 meaning a = 0, b = 0.01, and c = 2.5. The receiver understands this to mean Vcell = 0 · x2 + 0.01 · x + 2.5

Let’s try it with a byte value of 163 as shown in the received telemetry data following:

Vcell = 0 ·1632 + 0.01 · 122 + 2.5

Vcell = 0 + 1.63 + 2.5 = 4.13 Volts

This is exactly what we had planned! This is how engineering and applied mathematics work in the real world.

Here is a sample of telemetry definitions from a D1M-WX1 weather station:

2018-10-09 15:53:32 EDT: W4KRL-15>APRS,TCPIP*,qAC,T2DENMARK:T#144,163,078,013,080,,1111,Solar Power WX Station
2018-10-09 15:53:32 EDT: W4KRL-15>APRS,TCPIP*,qAC,T2DENMARK::W4KRL-15 :PARM.Vcell,RSSI,Light,Awake,,BME28,BH17,loV,loS
2018-10-09 15:53:32 EDT: W4KRL-15>APRS,TCPIP*,qAC,T2DENMARK::W4KRL-15 :UNIT.Vdc,dBm,lux,secs,,OK,OK,OK,OK
2018-10-09 15:53:32 EDT: W4KRL-15>APRS,TCPIP*,qAC,T2DENMARK::W4KRL-15 :EQNS.0,0.01,2.5,0,-1,0,1,0,0,0,0.1,0
2018-10-09 15:53:32 EDT: W4KRL-15>APRS,TCPIP*,qAC,T2DENMARK::W4KRL-15 :BITS.Solar Power WX Station

DIY Instrument Shield

An instrument shelter provides a flow of air around weather sensors while protecting them from direct sunlight and rain. Without a shield, the sun can heat the temperature sensor giving a false high-temperature reading.

Professional weather stations use a large louvered box called a Stevenson Screen that is built to specific dimensions for standardized weather measurements. Smaller plastic shields can cost $100 or more. My station uses an AcuRite Radiation Shield that sometimes sells for as little as $10. Making your own instrument shelter can be an easy and fun project that may cost less than $6.

These instructions will give you a general idea how to build a shield. You can easily adapt the design to the materials you can find. The basic item is a shallow dish with nearly vertical straight sides. Dishes made as plant saucers are an excellent choice. The dishes are stacked on top of each other separated by beads and held together by wire ties. It makes a surprisingly sturdy design.

Here are suggested items. Any reasonable substitute will work if you can’t find these exact items:
• Dotchi 4-in Clear Plastic Plant Saucer – Lowe’s #606062 – $0.34. Buy six and maybe a few spares.
• Valspar White Spray Paint – Lowe’s #282255 – $0.99.
• Nylon Wire Ties – 6 to 11-inches long – Dollar Tree $1.00 or Harbor Freight $2.00
• Plastic or wood craft beads of the “large hole” variety. The hole must be large enough to allow the wire tie to pass through – Dollar Tree or Michael’s

You need to have at least six small saucers with flat bottoms and steep shallow sides. Plant saucers of 4 to 6-inch inch (100 mm – 150 mm) diameter work well. They are very thin so larger saucers are not strong enough. Paint them white with spray paint inside and out.

After the paint is dry, cut a hole in the flat bottom of five of the saucers leaving a ring at least 1/4-inch (6 mm) wide. The sixth uncut saucer will be the top of the shield. The holes should be a little larger than the width of the weather station printed circuit board, say 1.75-inches (45 mm). Cut three small slots wide enough to pass the tail of a wire tie in the flat bottom ring of each saucer. The slots must all line up. One way to do this is to make three equally spaced guide marks on the top saucer with a permanent marker. Place each of the other saucers over the top one and put marks in the same places. You can see the guide marks by holding them up to a light. Cut short slots at all the marks with a craft knife.

Look at how wire ties work: one side of the tail is smooth, the other side has ridges that engage with a tongue in the head of the tie.

Place the tail of a wire tie through each of the slots in the top saucer with the ridged side facing the center of the saucer hole. Put at least two beads over the tails of the wire ties coming out the other side of the saucer and thread them through the holes in the next saucer. Do this for each saucer.

You should now have a loose stack of saucers with three wire ties sticking out the bottom. Place a bead on each of the wire ties, then carefully press the head of another wire tie over each tail. You can tighten these up by hand to hold the stack firmly together. The tails of the new wire ties will cross more-or-less in the center of the bottom saucer. Cut three small slots in the side of the bottom saucer opposite from each wire tie. You can gently pry up the tails and insert the LiPo cell and weather station PCB into the hole with the solar cell outside. Pass the tails through the slots to secure the weather station in the shield.

Mounting the station is up to you. One possibility is to pass wire tie tails through the heads in the top of the shield and fasten them to some convenient bracket. For a few dollars more, buy a set of magnetic hooks like the ones Harbor Freight sells as item # 98502. Before you put your station inside the shield, drop a 1-1/2-inch (40 mm) steel (not stainless) washer into the shield. Place the magnetic hook on the other side so that it attracts the washer.

Solar Radiation Shield under test

The D1M-WX1 and D1S-WX1 solar-powered weather stations heat up in direct sunlight giving an incorrectly high-temperature reading. Early results from testing an Acurite solar radiation shield are very good.

The shield is available from several online vendors. Check around for a good price as the same item sells for $10 to $60 from different vendors.

https://www.acurite.com/solar-radiation-shield.html

I inserted a D1S shield-type station into the Acurite product and hot-melt glued the solar panel to the side of the solar shield. The shield comes apart by carefully prying small plastic tabs between each layer. This makes it easy to run wires into the shield.

On sunny days, the unshielded sensor heats up by more than 20ºC (36ºF) compared to the sensor in the AcuRite shield.

Since product availability is problematic, I am going to look into the possibility of building a DIY solar shield with dollar store components.

Power supply measurements

Most electronic projects operate on low voltage direct current. This is often provided by a USB connection or a battery. There are several possibilities to power a project from the 120 Vac power line. A common way is to use a wall adapter (wall wart) and feed low voltage direct current to your project through a power connector. A good feature of this approach is that the project enclosure is smaller because it does not need to house a power supply.

If you have a project that controls line power, like a Wi-Fi controlled receptacle, it is more convenient to incorporate the power supply in the project enclosure so that you do not need to connect to both the power line and a wall adapter. The solution is to include the guts of a wall adapter into the project enclosure.

Rather than taking apart a wall adapter, you can buy a phone charger kit from eBay vendors. Try searching for “diy training phone charger kit”.

According to the eBay listings, the specification is 5 Vdc at 350 mA to 500 mA with an input of 100-220 V 50//60Hz 0.3 A. This would be adequate for many Arduino and ESP8266 projects, sadly, the supply can barely meet 170 mA.

Next step is to modify the circuit to see if the output can be raised. Short out R7 and play around with R2, R3, and C2.

Di Mini (ESP8266) Wi-Fi Status Codes

The ESP8266 using the Arduino Core reports Wi-Fi status with the WiFi.status() function. The D1M-WX1 Weather Station attempts to connect to Wi-Fi every 250 milliseconds until the “Connect” status is found. If this does not happen after 15 attempts, it prints the status to the Serial Monitor.

Normally, the LED on the ESP8266 flashes five or six times until the connection is made. The LED will be dark during the six or seven seconds it takes to post the weather data on the Internet.  It will flash three times before the station goes to sleep for 10 minutes. The code is in the logonToRouter() function of the weather station sketches.

If a Wi-Fi connection can not be made, the LED will flash 16 times and the exit code will appear on the Serial Monitor. The status codes are:

ESP8266 WiFi Result Codes

CodeMeaningDescription
1No SSID AvailableUnit is too far from the Wi-Fi access point, the SSID and/or password is incorrect, or the SSID is for a 5GHz-band access point.
2Scan CompletedScanning for available networks is completed.
3ConnectedSuccess
4Connection FailedThe opposite of success.
5Connection Lost
6Disconnected
255No ShieldUsed for compatibility with the Arduino WiFi Shield - not relevant to the ESP8266.

Reference: https://www.arduino.cc/en/Reference/WiFiStatus

Sleep Mode for the Wemos D1 Mini

The key to using solar power in an Internet of Things project is to put the microcontroller unit into sleep modeafter the sensors are read and the data posted to your IoT server. The NodeMCU and the Wemos D1 WiFi, a larger profile that mimics the Arduino UNO form, reliably woke from deep sleep. So far, the Adafruit HUZZAH fails to wake after 20 or 30 sleep cycles. I’m still working on the HUZZAH but the letter carrier just brought a package with three Wemos D1 Mini ESP8266 devkits and an OLED display shield.

Would the D1 Mini also work well with deep sleep? Answering that question had to wait until I checked out the OLED display.

The D1 Mini devkits are supplied with both male and female headers. You must install the female headers if you want to use the OLED shield as a plug-in unit. Make sure you install the headers on the correct side so that the shields will stack with correct connections.

Both Adafruit and Sparkfun have Arduino libraries for this display. The Sparkfun library loaded easily and the examples brought up bright, clear images.

The next step was to make a DIY shield to mount BMP180 and HT21D sensors. The BMP180 measures atmospheric pressure and temperature. The HTU21D measures temperature and humidity. [I will post some photos in a week.] It makes a nice compact little cube with the sensor shield stacked between the D1 Mini and the OLED.

Having proven the OLED display, I removed it and set about to put the D1 Mini and sensor shield into deep sleep. There were some problems doing this. When the ESP8266 wakes up, it needs to be reset to restart execution of the firmware. The ESP8266 provides a signal on pin D0 to do this so D0 must be connected to the Reset pin. However, this connection sometimes interferes with putting the ESP8288 into programming mode and must be opened to reprogram the chip.

I also ran into some problems when power was removed while the chip was in deep sleep.

After getting the chip to sleep and wake up I ran some current tests. The D1 Mini drew an average of 80mA when awake and 2.4mA when asleep. The D1 Mini has a small red LED that lights when the board is powered. I pulled the LED off the board with a pair of pliers. That dropped the sleep current down to 70µA.  This makes the D1 Mini look like a very good choice for solar powered IoT projects.

Load more