Library for PTSolns ESP32 microWatt
Although it is recommended that novice users install the microWatt Support Library (mSL), this library is NOT a requirement, or a must, in order to use the ESP32 microWatt microcontroller. The mSL can be used optionally to assist with various tasks or as a general help.
Various examples are included in this package. For any comments or questions please contact us at contact@PTSolns.com.
-
microWatt.begin(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int LED = 13, int number_of_blink = 4, int time_between_blink = 50) which are passed to microWatt.blink() (see below).
-> This starts the mSL with some useful printouts.
-> Starts Serial if it was not initiated prior.
-> Sets up .blink() (see below).
-> function returns int mLS_code (see below).
-> See /examples/GettingStarted/GettingStarted.ino for a detailed Arduino IDE example sketch. -
microWatt.blink(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int LED = 13, int number_of_blink = 4, int time_on_blink = 50, int time_off_blink = 50).
-> Makes LED blink ON and OFF number_of_blink. Uses millis() for measuring durations, therefore there is no induced delay.
-> See /examples/Blink/Blink.ino for a detailed Arduino IDE example sketch.- microWatt.blinkDelay(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int LED = 13, int number_of_blink = 4, int time_on_blink = 50, int time_off_blink = 50).
-> Makes LED blink ON and OFF number_of_blink. Uses delay() instead of millis().
-> See /examples/Blink/Blink.ino for a detailed Arduino IDE example sketch.
- microWatt.blinkDelay(optional arguments)
-
microWatt.printPinout()
-> No arguments to pass.
-> Prints the pinout of the microWatt -
microWatt.setI2Cpins(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int SDA_pin = 21, const int SCL_pin = 22).
-> Set I2C pins.
-> Initiates Wire.begin(SDA_pin, SCL_pin).
-> function returns int mLS_code (see below). -
microWatt.printI2Cpins()
-> No arguments to pass.
-> Print out the I2C pins (whether default or specified previously using microWatt.setI2Cpins()). -
microWatt.printSPIpins()
-> No arguments to pass.
-> Print out the SPI pins. -
microWatt.I2Cscan(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int SDA_pin = 21, const int SCL_pin = 22).
-> Performs I2C scan to check for any address of connected peripherals.
-> If no arguments are supplied, then either default I2C pins are used for the scan, or a previously specified set of pins using microWatt.setI2Cpins().
-> NOTE: if not already previously called, this function will initiate Wire.begin().
-> See /examples/Sensor_via_I2C/Sensor_via_I2C.ino for a detailed Arduino IDE example sketch. -
microWatt.fade(optional arguments)
-> Arguments can be left blank (uses defaults), or input (const int LED_pin = LED_buildIn, const int PWM_Channel = 0, const int PWM_freq = 500, const int PWM_res = 8, int fade_inc = 5, int time_step = 20).
-> Using a PWM fade in and out an LED.
-> PWM_pins = {G0, G1, G2, G3, G4, G5, G12, G13, G14, G15, G16, G17, G18, G19, G21, G22, G23, G25, G26, G27, G32, G33}.
-> Alternatively to check what the PWM_pins are use microWatt.printPinout() and check the Serial Monitor on baud rate 115200.
-> WARNING! Although G1 (TX) and G3 (RX) can be used as PWM pins, but they may interfere with Serial Monitor. Use other pins if possible. -> See /examples/Fade/Fade.ino for a detailed Arduino IDE example sketch. -
microWatt.deepSleep(uint32_t duration)
-> Input the duration in seconds to remain in deep sleep. -
microWatt.lightSleep(uint32_t duration)
-> Input the duration in seconds to remain in light sleep. -
microWatt.setFreq(uint32_t CPUfreq)
-> Input CPU frequency measured in MHz.
An integer return value from various functions.
- = 0 -> Everything is OK
- = 1 -> Relating to Serial. Likely Serial.begin(baud rate) was not called BEFORE any microWatt commands, and hence it was initiated by the microWatt Support Library. Otherwise, check baud rate. If microWatt Support Library initiated Serial, it would be on Serial.begin(115200).
- = 2 -> I2C pins have been set manually AND Wire.begin() has been initiated using either the default pins or specified pins using microWatt.setI2Cpins().
In order for the ESP32 microWatt to be programmed, your computer will need the CH340 driver. If you try to program the ESP32 microWatt and it doesn't work, try installing the driver first. Sparkun has a great tutorial on this!
- If Serial.begin(baud rate) has not been initiated before the BEGIN call, then the mSL will do so using baud rate Serial.begin(115200). If nothing prints to Serial monitor, ensure baud rate is set to 115200.
- The mSL uses an integer code called mSL_code to keep track on what is happening. Many functions return this value after being called. You can print out the mSL_code and check the reference as to what it means.
- Make sure to install the CH340 driver (see above).