Open mavishak opened 3 years ago
After vigorous research, we reached the following conclusions:
ESP8266 can be used as a Web Client or Server:
(see the following links)
Using Firestore with IoT Core for device configuration
Using Firestore with Cloud IoT Core for Device Configuration - LAB
In this lab you will learn how to configure Cloud Functions for Firebase to relay document changes in Cloud Firestore as configuration updates for Cloud IoT Core Devices.
In order to send data from the STM to Firebase we want our ESP to act as a Web Client. There are ALOT of examples for doing this with ArduinoIDE but as of now, we haven't found out how to use this information as we are writing in C with STM32CubeIDE.
It seems that either way the other way to set up the communication is by using AT-Commands using USART between the STM device and the ESP. We found out that a simple way to test this connection is to send a <AT+ENTER> command to the ESP device and see that we receive an answer (OK).
These are links that might help us: STM32 IoT with ESP8266 - (Youtube With HAL) ELECTRONICS HUB - ESP8266 - (there are a lot of examples most in Arduino but it might help) ESP8266-STM32F103 (GitHub) - (This is a link to a repository that uses stm32f10x.h - seems to be doing exactly what we are aiming for might be helpful )
14/01/2021: We connected the STM32 device with the Wi-Fi module (pictures are attached below). We started a test project, where we used a repository: ESP8266-STM32F103 (which uses the STM32F10x Standard Peripherals Library) Attempte to send AT command failed. Need to keep working on it.
(click to enlarge)
ESP8266-Firebase-AVR-ThingSpeak - An example (it seems that Arduino is used with C). Data is sent using ThingSpeak which we already have an account to. Firebase-ESP8266 - (Same as above - seems very clear) ThingSpeak - We created an acount
22.01.2021: Setting the baselines for USART1 for communication with ESP8266 MADE A FEW SMALL CHANGES TO USART2 init:
changed static USART_2 usart2; //changed from buff need to check that it is still working...
23.01.2021: Writing code for USART1 - communication with ESP8266 NOTE: Code not tested yet. Questions:
24.01.2021: We haven't succeeded to create a connection with ESP8266. the interrupt is not accessed. (We accessed it by mistake after touching the pins)
What we tried and didn't work:
Enable RCC for Alternate function for PINs - Highly unlikely... we don't think it should be enabled at all.
On another subject - The init_usart1() test prints are printed twice even though they are supposed to print once. We are pretty sure that the BRR is set correctly (but it might be worth the review...)
25.01.2021: We are managing to get input from ESP8266 but not the correct one:
After a meeting with our instructor:
I am not completely sure but it seemed I managed to create a connection between STM32 and ESP8266 using the code from ESP8266-STM32F103. This is my main:
#include <stm32f10x.h>
#include <stm32f10x_rcc.h>
#include <stm32f10x_usart.h>
#include "USART.h"
#include "common.h"
#include "ESP8266WIFI.h"
int main(void)
{
USART2_Configuration(); // for PC
USART1_Configuration(); // for ESP2866
//sysTickInit();
//delay(10000); //1sec
while(1){
//usartSendArrar(USART2, (uint8_t*)"hello_stich\r\n");
//delay(1000); //1sec
bool test_passed = esp8266Test();
if(test_passed){
usartSendArrar(USART2, (uint8_t*)"Test Passed\r\n");
}
else{
usartSendArrar(USART2, (uint8_t*)"Test Failed\r\n");
}
//delay(2000); //2sec
}
}
One small change: in USART.c _void USART1Configuration() I changed the baud rate to 115200 instead of 9600. And of course, I connected the (EN) CH_PD to 3.3V
After printing USART1 content of esp8266RxBuffer to the screen we saw the 'OK\r\n' So unless something is going on in the code that we are not aware of the code does indeed enable communication between STM32 and ESP8266.
We also saw that when printing that similar to our program there are two printouts instead of one.
28.01.2021: ESP8266 is communicating with STM32 The 2 main things we changed:
We allowed Rx and Tx to be enabled all the time
One strange thing, it seems the ESP8266 Response is AT\r\n\r\nOK\r\n"
References:
ESP8266 - WiFi Module (COMPONENTS 101) - This site was used in order to understand the HC-SR501 PIR Sensor. turning out to be very helpful (so keep note...). Contains pin mapping and normal configuration (along with some other useful information).
Note: the image and quats above were taken from the site listed above.
ESP8266 AT Instruction Set (pdf) - _This document provides AT commands list based on ESP8266_NONOSSDK.