1

I would like to use the Raspberry PI Pico to monitor exchange rates for crytpo currencies and inform me via SMS (using a SIM800l module) when certain prices are exceeded or fallen short of. I successfully connected the Pico to an ESP-01S, following this tutorial. It can controlled through AT commands (e.g. I can retrieve the IP address).

I want to use Micropython. But how do I send the following request using AT commands?

import urequests.urequests as requests

url = 'https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC&tsyms=EUR'
price_euro = requests.get(url).json()

I could not find anything helpful on Google.

2
  • 1
    The ESP-01 module should work find for providing basic connectivity to the Pico, you'll have to communicate through the AT interface over UART a bit tedious, but the docs are very thorough.
    – Alicia
    Feb 24, 2021 at 23:01
  • 1
    Once you've connected the ESP to your network (using AT commands, e.g. AT+CWJAP="SSID","password"), then you can make a connection to your your server (again with AT commands, like AT+CIPSTART=”TCP”, “server”, port). Next connect the Pico up to your ESP (you'll have to refer to the data sheet for the exact pins). You should now be able to interface with these pins to send and receive network requests to the API on your server.
    – Alicia
    Feb 24, 2021 at 23:01

3 Answers 3

2

StackExchange will not let me comment but I'm not convinced this is currently do-able as the ESP01 AT commands only provide raw data stream handling such as:

AT+CIPSEND=<length>;
+IPD

to send / receive.

Neither Circuit Python or Micropython has support built in for DNS / HTTP so you would be looking at fitting something like the Adafruit ESP32SPI library and then building the requests module on top. Note this also requires the ESP32 to have code loaded on it to handle the SPI.

For now I would:

  1. Look to help MicroPython or CircuitPython teams to improve library support

and

  1. Move chipset to an ESP32 / ESP8266 based MCU that supports the WiFi libraries
  2. Possibly move to a Pi Zero W and use Python3?

or

  1. See if this can be done in C (no idea)

or

  1. Create a C program on the ESP01 to pull the data from the site
  2. Pass this data via serial to the Pico
  3. Process this on the Pico
  4. Pass a 'send message' to the ESP01

We know from Ebens tweet and tweet that the chips are going out to board makers so it will be a race to see who can get a WiFi stack working first (Adafruit / Pimoroni / SparkFun / Arduino) with their board. Problem is this will not solve your issue as they are all looking to make their own versions of the Pico.

1
  • 1
    Thanks for your answer. I already thought about the possibility to use a Pi Zero W. So I will try this next. Feb 24, 2021 at 18:19
1

I have been wanting to do something like this too. I came across this. It is not in micropyhon but maybe it can help you. https://github.com/s60sc/PicoWebServer

0

If you're willing to switch to CircuitPython then I recently wrote some simple code to use the (Maker) Pi Pico with an ESP-01S. It's using MQTT but you can see adafruit_requests library in there commented out. It can be used for making HTTP requests over TLS, I used it briefly for some debugging. The libraries deal with all the underlying AT commands.

  1. Instructables: Publishing Particulate Matter Sensor Data to Adafruit IO With Maker Pi Pico and ESP-01S - that covers getting the ESP-01S working with the Pico
  2. pmsensors-adafruitio.py - my code from above article
  3. requests_simpletest.py - one of the (ESP32 based) library examples using adafruit_requests

Picking out the relevant parts of code from 2 and 3 should give you a working solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.