ESP32 + analogRead()

The ESP32 is the new chip-on-the-block for Internet of Things, having both wi-fi and bluetooth. I have a breakout board from They are coming down in price and can be found for under £7. This breaks out many(but not all) of the pins. I wanted to use a temperature sensor TMP36 and use analogRead() like in That example was for the ESP8266.

However, being relatively new, the ESP32 does not support reading an analog input using that simple analogRead() that you find in the arduino ide.

Actually, I just worked out it dosen’t support analogWrite() at  the moment, analogRead() works fine. However, it gave me a chance to learn about other environments for the esp32.

So it’s off to download and install the “Espressif IoT Development Framework”

Read the docs on ADC

The ADC driver API currently only supports ADC1 (9 channels, attached to GPIOs 32-39).

The only goes to GPIO 35, so we have 4 to play with. Compiling and flashing the adc1_test, in /examples/peripherals/adc/main/adc1_test.c
ADC1_CHANNEL_4 is used, from the docs ADC1 channel 4 is GPIO32

<pre class="lang:c decode:true">/* ADC1 Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "driver/adc.h"

#define ADC1_TEST_CHANNEL (4)

void adc1task(void* arg)
    // initialize ADC

void app_main()
    xTaskCreate(adc1task, "adc1task", 1024*3, NULL, 10, NULL);

The analog read worked, but the temperature sensor was a bit funny. So I tested it with a rain-detector, which seemed to give reasonable results.



Spoiled for Choice: STEM and new micro-controller platforms

As a father of a toddler, and an interest in electronics, I am always on the lookout for what might be interesting to her.

Engoyed reading about learning to code by Adrian Oldknow Latest documents: Learning to Code 1, Learning to Code 2, Learning to Code 3  

In the last 5 years there has been an explosion in platforms (both software and hardware), the learning to code series looks at 12 combinations from pic to arduino to raspberry pi.

Now there is a growing group aimed at youngsters, cheap badge microcontrollers with easy attachment.

3 uk based products that interest me. Only the last one is currently available. There is the MicroBit that will be given to school children in uk in yr 7, The CodeBug that is on kickstarter and the Crumble, which can be bought now for £12. I Dont have them, but it would be nice to get all three to compare there strengths and weaknesses(hint hint).


Micro Bit

release version micro:bit 


Code Bug (currently on kickstarter, by the PiFace people)



and my current favourite

Crumble Microcontroller, by redfern electronics

Crumble Microcontroller