RSS

Archive for July, 2016

Adding Another Micrcontroller

Saturday, July 9th, 2016

Last time the prototype was moved from breadboard to perfboard. The schematic had a couple of components for the rain gauge and one additional ADC to compensate for the fact that the ESP8266 only has one ADC on board. These three components added a reasonable cost to the board and it was hinted that another microcontroller maybe added to the system to replace these components.

Enter the STM8S.

Hardware Modifications

The previous schematic looked as follows:

Weather Station Schematic

Weather Station Schematic

Three components are being targeted for replacement:

  1. 74HC4040 – counter
  2. MCP23017 – I2C output expander
  3. ADS1115 – 4 channel ADC

These components come to several pounds (dollars) worth of components. It may be possible to replace these with the STM8S and a little software.

ESP8266 Low Power Mode

A long term goal of the project is to reduce the power consumed by the system in order to allow the system to work from a battery / solar energy source. In order to work towards this goal the system should be looking to shut off as much of the system as possible when they are not needed.

Initial thoughts are that the system should collect data every 5 minutes. This means that most of the system is only required for a few seconds (say 10 seconds) every five minutes.

One exception is the rain gauge. This needs to be counting all day, every day as a sample taken at a point in time is not representative of the rain fall for a full day.

Another exception is the Real Time Clock (RTC). This needs to be running all of the time for two reasons, firstly it keeps track of the current date and time. Secondly, the system can generate an interrupt to wake the system on a regular basis.

Adding Another Microcontroller

Regular readers will no doubt be aware that I have been a regular user of the STM8S. This microcontroller is available in packages starting at around £0.72 (about $1). Even the smallest packages have several ADCs and multiple digital input / outputs potentially reducing the system costs.

One other area that a microcontroller can help is with the chosen RTC, the DS3234. This RTC can generate an interrupt when an alarm time is reached. The interrupt generated is a simple high to low transition. The ESP8266 however requires a pulse. The STM8S can help by providing this conversion, detecting the falling edge and generating a pulse for the ESP8266.

Sounds perfect.

Updated Schematic

Several previous posts have shown that it is possible to perform analog conversions and also capture interrupts. This makes it possible for the STM8S to gather several sensor readings for the Oak and replace some components, namely:

  1. ADS1115 4 channel ADC – The STM8S has several ADC channels and the system only requires 2 so far
  2. MCP23017 I2C Port Expander – Several digital channels remain available even after using some pins for the ADC
  3. 74HC4040 Counter – This functionality can be provided through software and a digital channel

Another attractive feature of this microcontroller is the ability to act as an I2C slave device. This will work well with the other digital sensors as they all use the I2C protocol, one protocol to rule them all.

A few changes to the schematic results in the following:

Weather Station Schematic Revision 0.01

Weather Station Schematic Revision 0.01

Focusing in on the STM8S:

STM8S On The Weather Station

STM8S On The Weather Station

The STM8S should be able to take over the reading values from the following sensors:

  1. Ultraviolet light
  2. Wind direction
  3. Wind speed
  4. Rain Gauge

All that is needed now is some software. Time to break out the compilers.

Conclusion

Adding a new microcontroller adds some complexity to the software development whilst reducing the cost of the final solution.

Next steps:

  • Putting the Oak to sleep and using the RTC to determine when to wake the Oak
  • Reading the sensors on the STM8S
  • Communication between the Oak and the STM8S over I2C