ESP32 Firmware Anfängerfrage

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Sascha1
New user
Posts: 6
Joined: 30 Jan 2020, 08:17

ESP32 Firmware Anfängerfrage

#1 Post by Sascha1 » 01 Feb 2020, 13:06

Moin,

Ich habe ein NodeESP32 Board, was mit einen ESPEasy Flash läuft. V2.0 Experimental
https://www.letscontrolit.com/wiki/index.php/ESPEasy32

Nun möchte ich aber so ein Plugin (INO) zusätzlich aktivieren um halt diesen Sensor GY-87 (drei Sensoren) MPC6050 auzulesen.
Ich hab nun alles Installiert, weil anscheinend Plugins nur mit in ein neues Flashfile geschrieben werden können.
Also Arduino installiert, über den Boardmanager das richtige Board Wemos Lolin32 Lite ausgewählt.

So jetzt fehlt mir die Info ob ich alle Biblotheken selber im Sketch auswählen muss, oder ob es ein vorgefertigtes Sketch gibt das so ist wie alle Firmwares von letscontrolit:

#include <Wire.h>
#include <ssl_client.h>
#include <WiFiClientSecure.h>
#include <ETH.h>
#include <WiFi.h>
#include <WiFiAP.h>
#include <WiFiClient.h>
#include <WiFiGeneric.h>
#include <WiFiMulti.h>
#include <WiFiScan.h>
#include <WiFiServer.h>
#include <WiFiSTA.h>
#include <WiFiType.h>
#include <WiFiUdp.h>
#include <Update.h>
#include <Ticker.h>
#include <SimpleBLE.h>
#include <SPIFFS.h>
#include <SPI.h>
#include <SD.h>
#include <sd_defines.h>
#include <sd_diskio.h>
#include <Preferences.h>
#include <NetBIOS.h>
#include <HTTPUpdate.h>
#include <HTTPClient.h>
#include <FS.h>
#include <FSImpl.h>
#include <vfs_api.h>
#include <FFat.h>
#include <ESPmDNS.h>
#include <ESP32WebServer.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <AzureIotHub.h>
#include <Esp32MQTTClient.h>
#include <AsyncUDP.h>
#include <EEPROM.h>
#include <DNSServer.h>
#include <BluetoothSerial.h>
#include <ArduinoOTA.h>
#include <dummy.h>

dann den Text aus dem Ino File selber rein kopieren muss? Oder gibt es da ein fertiges Grund Konfig Sketch?

Hier müsste doch auch etwas rein oder?
void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

Gruß Sascha

stefbo
Normal user
Posts: 19
Joined: 24 Apr 2016, 15:35
Location: Germany

Re: ESP32 Firmware Anfängerfrage

#2 Post by stefbo » 05 Feb 2020, 22:53

Hi Sascha,
hast Du schon ein fertiges image für esp32 aus dem aktuellen release probiert? ESP_Easy_mega-20200204_test_ESP32_4M316k.bin sollte den plugin für MCP schon enthalten. (https://github.com/letscontrolit/ESPEasy/releases)

Stefan

Sascha1
New user
Posts: 6
Joined: 30 Jan 2020, 08:17

Re: ESP32 Firmware Anfängerfrage

#3 Post by Sascha1 » 10 Feb 2020, 11:13

Hi Stefan,
sorry hatte schon aufgegben das hier einer Antwortet, deshalb meld ich mich erst jetzt.
Okay ich muss mal bei den Relase mich umschauen und bekommeda evtl ein kompletes Arduino Projekt, habe aber die letzten Relase versucht zu flashen, aber die laufen nicht.

Ich habe hier gelesen viewtopic.php?t=6354 das es nur mit der R20100 Release klappt.
Aber da ist halt die ino für den MPU6050 nicht drin

Die würde ich versuchen nach zu programmieren, mit der alten Arduino Core 2017-12-19
und dann folgende Ino's deaktivieren:
_N002_Buzzer.ino
_P010_BH1750.ino
_P016_IR.ino
_P035_IRTX.ino
_P049_MHZ19.ino
_P052_SenseAir.ino

und das _P045_MPU6050.ino dazu kompelieren.

Gruß
Sascha

Sascha1
New user
Posts: 6
Joined: 30 Jan 2020, 08:17

Re: ESP32 Firmware Anfängerfrage

#4 Post by Sascha1 » 11 Feb 2020, 13:02

Moin Stefan,

so hab jetzt was hinbekommen, konnte das alte Release zusammen stellen und den Treiber Plugin für den MPU6050 hinzufügen und bin erstellen, Sensor läuft jetzt,

Gruß
Sascha

stefbo
Normal user
Posts: 19
Joined: 24 Apr 2016, 15:35
Location: Germany

Re: ESP32 Firmware Anfängerfrage

#5 Post by stefbo » 14 Feb 2020, 00:02

Hi Sascha,
ich nutze meist ESP8266'er, habe aber auch eine ESP32 selbst geflasht, allerdings mit VisualStudioCode mit PlatformIO. Compile und upload haben wunderbar funktioniert....
Stefan
BTW: Können wir auf Englisch weiterdiskutieren, dass die anderen Forumteilnehmer auch was davon haben? Sonst per private message...

Dondolo
Normal user
Posts: 77
Joined: 03 Jul 2019, 06:56
Location: Germany

Re: ESP32 Firmware Anfängerfrage

#6 Post by Dondolo » 04 Apr 2020, 12:54

..I am using the version 20200310dev and there the plugin is already integrated.

Sascha1
New user
Posts: 6
Joined: 30 Jan 2020, 08:17

Re: ESP32 Firmware Anfängerfrage

#7 Post by Sascha1 » 05 Apr 2020, 12:50

Hi,

thank you for the information, but i have make my own firmware with platformio, the sensor MPU6050 works now.

My next problem is the HMC5883L Sensor, it is on the GY-87, over the I2C.

I have found the clear _Pxxx_PluginTemplate.ino

The i have found I2C_Sensor.h, HMC5883L.h

I must go this way, the ESP32 dont work with the last updates, the last firmware it works ist in the year 2018.

I have the firmware ESPEasy-mega-20180625 , modify whit the MPU6050.ino, it works.

Here's the code I'm trying to get going. But errors in platformio on must.

Code: Select all

/* This file is a template for Plugins */

/* References:
https://www.letscontrolit.com/wiki/inde ... evelopment
https://www.letscontrolit.com/wiki/inde ... Guidelines
https://github.com/letscontrolit/ESPEas ... Playground
https://diyprojects.io/esp-easy-develop-plugins/

A Plugin should have an ID.
The official plugin list is available here: https://www.letscontrolit.com/wiki/inde ... lugin_list
The plugin playground is available here: https://github.com/letscontrolit/ESPEas ... Playground

Use the next available ID. The maximum number of Plugins is defined in ESPEasy-Globals.h (PLUGIN_MAX)

The Plugin filename should be of the form "_Pxxx_name.ino", where:
xxx is the ID
<name> is a short name of the Plugin
As an example: "_P001_Switch.ino"

Hints for plugin development:
- plugins should ideally be added without changes in the framework
- avoid including libraries. Include the necessary code in the plugin
- when verifying the plugin check the following:
- memory used (try different scenarios: plugin enabled, plugin in use, commands executed, plugin disabled, device added/removed)
- other tests??
- the development life-cycle is:
- implement plugin and perform testing
- set plugin status to DEVELOPMENT and distribute to other users for testing
- after sufficient usage and possible code correction, set plugin status to TESTING and perform testing with more users
- finally, plugin will be accepted in project
- along with the plugin source code, prepare a wiki page containing:
- instructions on how to make the necessary configuration
- instructions on commands (if any)
- examples: plugin usage, command usage,...
- when a plugin is removed (deleted), make sure you free any memory it uses. Use PLUGIN_EXIT for that
- if your plugin creates log entries, prefix your entries with your plugin id: "[Pxxx] my plugin did this"
- if your plugin takes input from user and/or accepts/sends http commands, make sure you properly handle non-alphanumeric characters correctly
- After ESP boots, all devices can send data instantly. If your plugin is for a sensor which sends data, ensure it doesn't need a delay before receiving data
- ensure the plugin does not create sideffects (eg. crashes) if there's no actual device connected
- check the device's return values. Ensure that if the device returns an invalid value, to use a value like 0 or null to avoid side-effects
- extra hints mentioned in: https://github.com/letscontrolit/ESPEasy/issues/698
*/
//#include section
//include libraries here. For example:
#include "Headers/Status.h"
#include "Headers/I2C_Sensor.h"
#include "Headers/HMC5883L.h"

//uncomment one of the following as needed
//#ifdef PLUGIN_BUILD_DEVELOPMENT
//#ifdef PLUGIN_BUILD_TESTING

#define PLUGIN_123
#define PLUGIN_ID_123 123 //plugin id
#define PLUGIN_NAME_123 "Kompass HMC5883L" //"Plugin Name" is what will be dislpayed in the selection list
#define PLUGIN_VALUENAME1_123 "X" //variable output of the plugin. The label is in quotation marks
#define PLUGIN_VALUENAME2_123 "Y" //multiple outputs are supported
#define PLUGIN_VALUENAME3_123 "Z" //multiple outputs are supported
#define PLUGIN_xxx_DEBUG false //set to true for extra log info in the debug

/*
PIN/port configuration is stored in the following:
Settings.TaskDevicePin1[event->TaskIndex] - The first GPIO pin selected within the task
Settings.TaskDevicePin2[event->TaskIndex] - The second GPIO pin selected within the task
Settings.TaskDevicePin3[event->TaskIndex] - The third GPIO pin selected within the task
Settings.TaskDevicePort[event->TaskIndex] - The port in case the device has multiple in/out pins

Custom configuration is stored in the following:
Settings.TaskDevicePluginConfig[event->TaskIndex][x]
x can be between 1 - 8 and can store values between -32767 - 32768 (16 bit)

*/

//A plugin has to implement the following function

boolean Plugin_123(byte function, struct EventStruct *event, String& string)
{
//function: reason the plugin was called
//event: ??add description here??
// string: ??add description here??

boolean success = false;

switch (function)
{
case PLUGIN_DEVICE_ADD:
{
//This case defines the device characteristics, edit appropriately

Device[++deviceCount].Number = PLUGIN_ID_xxx;
Device[deviceCount].Type = DEVICE_TYPE_SINGLE; //how the device is connected
Device[deviceCount].VType = SENSOR_TYPE_SWITCH; //type of value the plugin will return, used only for Domoticz
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 0; //number of output variables. The value should match the number of keys PLUGIN_VALUENAME1_xxx
Device[deviceCount].SendDataOption = false;
Device[deviceCount].TimerOption = false;
Device[deviceCount].TimerOptional = false;
Device[deviceCount].GlobalSyncOption = true;
Device[deviceCount].DecimalsOnly = true;
break;
}

case PLUGIN_GET_DEVICENAME:
{
//return the device name
string = F(PLUGIN_NAME_123);
break;
}

case PLUGIN_GET_DEVICEVALUENAMES:
{
//called when the user opens the module configuration page
//it allows to add a new row for each output variable of the plugin
// strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_xxx));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_123));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_123));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_123));
break;

break;
}

case PLUGIN_WEBFORM_LOAD:
{
//this case defines what should be displayed on the web form, when this plugin is selected
//The user's selection will be stored in
//Settings.TaskDevicePluginConfig[event->TaskIndex][x] (custom configuration)

// Make sure not to append data to the string variable in this PLUGIN_WEBFORM_LOAD call.
// This has changed, so now use the appropriate functions to write directly to the Streaming
// WebServer. This takes much less memory and is faster.
// There will be an error in the web interface if something is added to the "string" variable.

//Use any of the following (defined at WebServer.ino):
//addFormNote(F("not editable text added here"));
To add some html, which cannot be done in the existing functions, add it in the following way:
addHtml(F("<TR><TD>Analog Pin:<TD>"));


For strings, always use the F() macro, which stores the string in flash, not in memory.

//String dropdown[5] = { F("option1"), F("option2"), F("option3"), F("option4")};
//addFormSelector(string, F("drop-down menu"), F("plugin_xxx_displtype"), 4, dropdown, NULL, Settings.TaskDevicePluginConfig[event->TaskIndex][0]);

//number selection (min-value - max-value)
addFormNumericBox(string, F("description"), F("plugin_123_description"), Settings.TaskDevicePluginConfig[event->TaskIndex][1], min-value, max-value);

//after the form has been loaded, set success and break
success = true;
break;
}

case PLUGIN_WEBFORM_SAVE:
{
//this case defines the code to be executed when the form is submitted
//the plugin settings should be saved to Settings.TaskDevicePluginConfig[event->TaskIndex][x]
//ping configuration should be read from Settings.TaskDevicePin1[event->TaskIndex] and stored

//after the form has been saved successfuly, set success and break
success = true;
break;

}
case PLUGIN_INIT:
{
//this case defines code to be executed when the plugin is initialised
void setup()
{
Wire.begin();

Status.begin();
Status.checkStatus(Magnetometer);
}



//after the plugin has been initialised successfuly, set success and break
success = true;
break;

}

case PLUGIN_READ:
{
//code to be executed to read data
//It is executed according to the delay configured on the device configuration page, only once


{
if(Magnetometer.getDataReadyFlag())
{
Magnetometer.read();
sFloatAxes scaled = Magnetometer.getScaled();
Status.printMessage("X = " + String(scaled.X) + "\tY = " + String(scaled.Y) + "\tZ = " + String(scaled.Z));

float X = String(scaled.X);
float Y = String(scaled.Y);
float Z = String(scaled.Z);

UserVar[event->BaseVarIndex] = X;
UserVar[event->BaseVarIndex+1] = Y;
UserVar[event->BaseVarIndex+2] = Z;
log += F(": X: ");
log += X;
log += F(" Y: ");
log += Y;
log += F(" Z: ");
log += Z;
break;



}


addLog(LOG_LEVEL_INFO, log);

//after the plugin has read data successfuly, set success and break
success = true;
break;

}

case PLUGIN_WRITE:
{
//this case defines code to be executed when the plugin executes an action (command).
//Commands can be accessed via rules or via http.
//As an example, http://192.168.1.12//control?cmd=dothis
//implies that there exists the comamnd "dothis"

if (plugin_not_initialised)
break;

//parse string to extract the command
String tmpString = string;
int argIndex = tmpString.indexOf(',');
if (argIndex)
tmpString = tmpString.substring(0, argIndex);

String tmpStr = string;
int comma1 = tmpStr.indexOf(',');
if (tmpString.equalsIgnoreCase(F("dothis"))) {
//do something
success = true; //set to true only if plugin has executed a command successfully
}

break;
}

case PLUGIN_EXIT:
{
//perform cleanup tasks here. For example, free memory

break;

}

case PLUGIN_ONCE_A_SECOND:
{
//code to be executed once a second. Tasks which do not require fast response can be added here

success = true;

}

case PLUGIN_TEN_PER_SECOND:
{
//code to be executed 10 times per second. Tasks which require fast response can be added here
//be careful on what is added here. Heavy processing will result in slowing the module down!

success = true;

}
} // switch
return success;

} //function

//implement plugin specific procedures and functions here
void p123_do_sth_useful()
{
//code

}

Any solutions ?

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 Firmware Anfängerfrage

#8 Post by TD-er » 06 Apr 2020, 16:06

What kind of PlatformIO errors?

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: ESP32 Firmware Anfängerfrage

#9 Post by ssd » 14 Sep 2020, 10:25

Sorry for posting it under this link but I am unable to create a new post.

I am using GPIO 16,17,18,191,21 as input pins from the switch to ESP32 but I cannot update the same in the hardware tab of ESPeasy. Why there are no more pins after GPIO16 in the hardware section of ESP32? Or is it still under development? I want to update these pins as "input" in the hardware tab of ESPeasy.

Thank You!

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 Firmware Anfängerfrage

#10 Post by TD-er » 14 Sep 2020, 10:36

Well the SettingsStruct we use was not updated on all aspects before we started using ESP32 builds.
ESP8266 only has GPIO 0 ..16, so there are no fields in the struct for more.

See this in the source code:

Code: Select all

  int8_t        PinBootStates[17];  // FIXME TD-er: this is ESP8266 number of pins. ESP32 has double.
It still has to be updated.
Just adding more fields will render the settings incompatible.
But now that I think of it, it is very well possible to split each byte into multiple ones as we only need 4 values.
Just have to check to make sure the ESP32 doesn't allow for more than 4 options.

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: ESP32 Firmware Anfängerfrage

#11 Post by ssd » 14 Sep 2020, 10:42

TD-er wrote: 14 Sep 2020, 10:36 Well the SettingsStruct we use was not updated on all aspects before we started using ESP32 builds.
ESP8266 only has GPIO 0 ..16, so there are no fields in the struct for more.

See this in the source code:

Code: Select all

  int8_t        PinBootStates[17];  // FIXME TD-er: this is ESP8266 number of pins. ESP32 has double.
It still has to be updated.
Just adding more fields will render the settings incompatible.
But now that I think of it, it is very well possible to split each byte into multiple ones as we only need 4 values.
Just have to check to make sure the ESP32 doesn't allow for more than 4 options.
okay. Until when we can expect the respective update or as it makes settings incompatible we have to stick with 16 pins in the future? Just curious so that I can make maximum use of the pins and not restricting myself to use a particular pin. :D

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 Firmware Anfängerfrage

#12 Post by TD-er » 14 Sep 2020, 10:48

Well as I am also working on a board design myself using ESP32, I guess I will also run into this quite soon. :)

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: ESP32 Firmware Anfängerfrage

#13 Post by ssd » 14 Sep 2020, 10:58

Okay. Cool..waiting for the update. :)
Thank You!!

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 Firmware Anfängerfrage

#14 Post by TD-er » 14 Sep 2020, 17:38


ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: ESP32 Firmware Anfängerfrage

#15 Post by ssd » 15 Sep 2020, 08:12

TD-er wrote: 14 Sep 2020, 17:38 Can you try this test build? https://github.com/letscontrolit/ESPEasy/pull/3254
will try that and let you know

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 Firmware Anfängerfrage

#16 Post by TD-er » 18 Sep 2020, 12:51

Have you already tried the test build?

ssd
Normal user
Posts: 53
Joined: 19 Aug 2020, 12:04

Re: ESP32 Firmware Anfängerfrage

#17 Post by ssd » 21 Sep 2020, 07:15

TD-er wrote: 18 Sep 2020, 12:51 Have you already tried the test build?
yes, I tried for a few GPIO it's working fine. Thanks!! :D

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests