Hi I'm trying to upload this code to my nodemcu 1.0 esp 12e but it keeps throwing an error expected declaration before end of line.
im new to coding and can't work this out at all.
/* CatamaranFreedom.com/dieselheater /
/ CatamaranFreedom.com/dieselheater */
/*************************************************************
This example runs directly on ESP8266 chip.
Note: This requires ESP8266 support package:
Please be sure to select the right ESP8266 module
in the Tools -> Board menu!
Change WiFi ssid, pass, and Blynk auth token to run ![]()
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>;
#include <RCSwitch.h>
#define DHTPIN 2 // D4
//Ta bort nedanstÄende piss
char* housecode = "10000";
char* socketcode1 = "10000";
char* socketcode2 = "01000";
char* socketcode3 = "00100";
char* socketcode4 = "00010";
char* socketcode5 = "00001";
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
// Voltagemeter
const int voltageSensor = A0;
float vOUT = 0.0;
float vIN = 0.0;
float R1 = 27000.0;
float R2 = 7900.0;
int value = 0;
//TEMP SENSOR START
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
// float vIN = 0.5;
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, t);
Blynk.virtualWrite(V6, h);
Blynk.virtualWrite(V7, vIN);
}
//TEMP SENSOR SLUT
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
//******************************************************************
// Create Class-Objects
//******************************************************************
RCSwitch mySwitch = RCSwitch();
//******************************************************************
// Setup Function
//******************************************************************
void setup()
{
// Initialize RCSwitch and select Pin which is used for sending the data
mySwitch.enableTransmit(4);
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
//******************************************************************
// Turn once Switches ON/OFF
//******************************************************************
BLYNK_WRITE(V0)
{
if(param.asInt()){
mySwitch.send("0011011010000101000001010000100"); // SWITCH av
digitalWrite(LED_BUILTIN, LOW);
}
else {
mySwitch.switchOff(housecode, socketcode1);
digitalWrite(LED_BUILTIN, HIGH);
}
}
BLYNK_WRITE(V1)
{
if(param.asInt()){
mySwitch.send("0011011010000101000010001111000"); // SWITCH plus
digitalWrite(LED_BUILTIN, HIGH);
}
else {
mySwitch.switchOff(housecode, socketcode2);
digitalWrite(LED_BUILTIN, HIGH);
}
}
BLYNK_WRITE(V2)
{
if(param.asInt()){
mySwitch.send("0011011010000101000000101000100"); // SWITCH minus
digitalWrite(LED_BUILTIN, LOW);
}
else {
mySwitch.switchOff(housecode, socketcode3);
digitalWrite(LED_BUILTIN, HIGH);
}
}
BLYNK_WRITE(V3)
{
if(param.asInt()){
mySwitch.send("0011011010000101000100011011000"); // SWITCH pÄ
digitalWrite(LED_BUILTIN, LOW);
}
else {
mySwitch.switchOff(housecode, socketcode4);
digitalWrite(LED_BUILTIN, HIGH);
}
}
BLYNK_WRITE(V4)
{
if(param.asInt()){
mySwitch.send("");
digitalWrite(LED_BUILTIN, LOW);
}
else {
mySwitch.switchOff(housecode, socketcode5);
digitalWrite(LED_BUILTIN, HIGH);
}
}
void loop()
{
Blynk.run();
timer.run();
value = analogRead(voltageSensor);
vOUT = (value * 5.0) / 1024.0;
vIN = vOUT / (R2/(R1+R2));
Serial.print("Input = ");
Serial.println(vIN);
delay(50);
}
Arduino: 1.8.14 Hourly Build 2020/12/15 11:34 (Mac OS X), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
In file included from /Users/michaelmorgan/Downloads/CatamaranFreedom_Dieselheater/CatamaranFreedom_Dieselheater.ino:27:0:
/Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFi.h:27:1: error: expected unqualified-id before 'extern'
extern "C" {
^
/Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFi.h:27:1: error: expected constructor, destructor, or type conversion before 'extern'
In file included from /Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/WiFiClientSecure.h:41:0,
from /Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/WiFiServerSecure.h:20,
from /Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFi.h:41,
from /Users/michaelmorgan/Downloads/CatamaranFreedom_Dieselheater/CatamaranFreedom_Dieselheater.ino:27:
/Users/michaelmorgan/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h:150:28: error: expected declaration before end of line
#pragma GCC diagnostic push
^
Multiple libraries were found for "DHT.h"
Used: /Users/michaelmorgan/Downloads/libraries/DHT-sensor-library-master
Not used: /Users/michaelmorgan/Downloads/libraries/Grove_Temperature_And_Humidity_Sensor
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.