For some time I discovered Arduino and I did a little 'bones with small simple projects and then sketches very simple and hassle, now I would like to go one step further and found a project that I would like to do, I have already created the pcb and soldered the components now I'm trying to program the microprocessor atmega 328 using compiler as Arduino.
Here is all the documentation and the sketch to be inserted into the chip with the various libraries and directories so far say I've gotten I downloaded the various libraries, but when I try to check the sketch gives me an error and I do not know what to do, tells me :
expected primary-expression before ")" token
On line 63 of the program
63 DallasTemperature sensors (& OneWire);
Thank you all
Re: Error compiling EmonGLCD sketch
Without knowing which sketch, I'm guessing that you don't have the 'OneWire' library installed.
http://openenergymonitor.org/emon/buildingblocks/installing-arduino-libr...
What the compiler is telling you is it does not understand "&oneWire", and I know that is a variable that is defined in that library. NOTE: it is "oneWire", not "OneWire". Here, "OneWire" is the type (like "int" or "double") and "oneWire" is a particular instance of that (like "y" or "Irms").
Line 63: "OneWire oneWire(ONE_WIRE_BUS);" is declaring an instance "oneWire" of some type "OneWire" that had been defined elsewhere - in fact it is a Class and it's defined in the library file OneWire.h.
Re: Error compiling EmonGLCD sketch
Hello Robert
I installed the library in the library OneWire Arduino but nothing gives me the same error
Re: Error compiling EmonGLCD sketch
To help us - help you...
I'm not this guy. You need to tell me more, like which sketch are you using.
Re: Error compiling EmonGLCD sketch
//------------------------------------------------------------------------------------------------------------------------------------------------
// emonGLCD Home Energy Monitor example
// to be used with nanode Home Energy Monitor example
// Uses power1 variable - change as required if your using different ports
// emonGLCD documentation http://openEnergyMonitor.org/emon/emonglcd
// RTC to reset Kwh counters at midnight is implemented is software.
// Correct time is updated via NanodeRF which gets time from internet
// Temperature recorded on the emonglcd is also sent to the NanodeRF for online graphing
// GLCD library by Jean-Claude Wippler: JeeLabs.org
// 2010-05-28 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
//
// Authors: Glyn Hudson and Trystan Lea
// Part of the: openenergymonitor.org project
// Licenced under GNU GPL V3
// http://openenergymonitor.org/emon/license
// THIS SKETCH REQUIRES:
// Libraries in the standard arduino libraries folder:
//
// - OneWire library http://www.pjrc.com/teensy/td_libs_OneWire.html
// - DallasTemperature http://download.milesburton.com/Arduino/MaximTemperature
// or https://github.com/milesburton/Arduino-Temperature-Control-Library
// - JeeLib https://github.com/jcw/jeelib
// - RTClib https://github.com/jcw/rtclib
// - GLCD_ST7565 https://github.com/jcw/glcdlib
//
// Other files in project directory (should appear in the arduino tabs above)
// - icons.ino
// - templates.ino
//
//-------------------------------------------------------------------------------------------------------------------------------------------------
#define RF69_COMPAT 0 // set to 1 to use RFM69CW
#include <JeeLib.h> // make sure V12 (latest) is used if using RFM69CW
#include <GLCD_ST7565.h>
#include <avr/pgmspace.h>
GLCD_ST7565 glcd;
#include <OneWire.h> // http://www.pjrc.com/teensy/td_libs_OneWire.html
#include <DallasTemperature.h> // http://download.milesburton.com/Arduino/MaximTemperature/ (3.7.2 Beta needed for Arduino 1.0)
#include <RTClib.h> // Real time clock (RTC) - used for software RTC to reset kWh counters at midnight
#include <Wire.h> // Part of Arduino libraries - needed for RTClib
RTC_Millis RTC;
//--------------------------------------------------------------------------------------------
// RFM12B Settings
//--------------------------------------------------------------------------------------------
#define MYNODE 20 // Should be unique on network, node ID 30 reserved for base station
#define RF_freq RF12_433MHZ // frequency - match to same frequency as RFM12B module (change to 868Mhz or 915Mhz if appropriate)
#define group 210
#define ONE_WIRE_BUS 5 // temperature sensor connection - hard wired
unsigned long fast_update, slow_update;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
double temp,maxtemp,mintemp;
//---------------------------------------------------
// Data structures for transfering data between units
//---------------------------------------------------
typedef struct { int power1, power2, power3, Vrms; } PayloadTX; // neat way of packaging data for RF comms
PayloadTX emontx;
typedef struct { int temperature; } PayloadGLCD;
PayloadGLCD emonglcd;
int hour = 12, minute = 0;
double usekwh = 0;
const int greenLED=6; // Green tri-color LED
const int redLED=9; // Red tri-color LED
const int LDRpin=4; // analog pin of onboard lightsensor
int cval_use;
//--------------------------------------------------------------------------------------------
// Flow control
//--------------------------------------------------------------------------------------------
unsigned long last_emontx; // Used to count time from last emontx update
unsigned long last_emonbase; // Used to count time from last emontx update
//--------------------------------------------------------------------------------------------
// Setup
//--------------------------------------------------------------------------------------------
void setup()
{
delay(500); //wait for power to settle before firing up the RF
rf12_initialize(MYNODE, RF_freq,group);
delay(100); //wait for RF to settle befor turning on display
glcd.begin(0x19);
glcd.backLight(200);
sensors.begin(); // start up the DS18B20 temp sensor onboard
sensors.requestTemperatures();
temp = (sensors.getTempCByIndex(0)); // get inital temperture reading
mintemp = temp; maxtemp = temp; // reset min and max
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
}
//--------------------------------------------------------------------------------------------
// Loop
//--------------------------------------------------------------------------------------------
void loop()
{
if (rf12_recvDone())
{
if (rf12_crc == 0 && (rf12_hdr & RF12_HDR_CTL) == 0) // and no rf errors
{
int node_id = (rf12_hdr & 0x1F);
if (node_id == 10) {emontx = *(PayloadTX*) rf12_data; last_emontx = millis();} //Assuming 10 is the emonTx NodeID
if (node_id == 15) //Assuming 15 is the emonBase node ID
{
RTC.adjust(DateTime(2012, 1, 1, rf12_data[1], rf12_data[2], rf12_data[3]));
last_emonbase = millis();
}
}
}
//--------------------------------------------------------------------------------------------
// Display update every 200ms
//--------------------------------------------------------------------------------------------
if ((millis()-fast_update)>200)
{
fast_update = millis();
DateTime now = RTC.now();
int last_hour = hour;
hour = now.hour();
minute = now.minute();
usekwh += (emontx.power1 * 0.2) / 3600000;
if (last_hour == 23 && hour == 00) usekwh = 0; //reset Kwh/d counter at midnight
cval_use = cval_use + (emontx.power1 - cval_use)*0.50; //smooth transitions
draw_power_page( "POWER" ,cval_use, "USE", usekwh);
draw_temperature_time_footer(temp, mintemp, maxtemp, hour,minute);
glcd.refresh();
int LDR = analogRead(LDRpin); // Read the LDR Value so we can work out the light level in the room.
int LDRbacklight = map(LDR, 0, 1023, 50, 250); // Map the data from the LDR from 0-1023 (Max seen 1000) to var GLCDbrightness min/max
LDRbacklight = constrain(LDRbacklight, 0, 255); // Constrain the value to make sure its a PWM value 0-255
if ((hour > 22) || (hour < 5)) glcd.backLight(0); else glcd.backLight(LDRbacklight);
}
if ((millis()-slow_update)>10000)
{
slow_update = millis();
sensors.requestTemperatures();
temp = (sensors.getTempCByIndex(0));
if (temp > maxtemp) maxtemp = temp;
if (temp < mintemp) mintemp = temp;
emonglcd.temperature = (int) (temp * 100); // set emonglcd payload
rf12_sendNow(0, &emonglcd, sizeof emonglcd); //send temperature data via RFM12B using new rf12_sendNow wrapper -glynhudson
rf12_sendWait(2);
}
}
This is the sketch that I am using
Re: Error compiling EmonGLCD sketch
// RFM12B Settings
//--------------------------------------------------------------------------------------------
#define MYNODE 20 // Should be unique on network, node ID 30 reserved for base station
#define RF_freq RF12_433MHZ // frequency - match to same frequency as RFM12B module (change to 868Mhz or 915Mhz if appropriate)
#define group 210
#define ONE_WIRE_BUS 5 // temperature sensor connection - hard wired
unsigned long fast_update, slow_update;
OneWire oneWire(ONE_WIRE_BUS); <<<<<<
I have here the error in this line
DallasTemperature sensors(&oneWire);
double temp,maxtemp,mintemp;
Re: Error compiling EmonGLCD sketch
That still points to the compiler not being able to find the library. I have just copied your sketch from your post above, copied the two other .ino files (icons & templates) and it compiled immediately for me.
Is your OneWire library in the same Libraries directory as JeeLib and Emonlib? Have you shut down the Arduino IDE COMPLETELY since you installed OneWire? (The libraries are read at start-up and held in memory. Leaving any IDE Window open means that the IDE does not start from nothing and does not read the libraries, which now include the new library, from disc.)
Re: Error compiling EmonGLCD sketch
Hello Robert
Today I could try to compile the program on another PC and everything worked properly , I can not understand why on my home PC is not working and it's all the same to this pc of my work , however, it does nothing I program it from here , the only thing tells me that memory is low and may not work properly .
Thanks again for your courtesy .
Christian
Re: Error compiling EmonGLCD sketch
It should be possible for you to take the compiler output from your work PC as a .hex file and load that into your GLCD using avrdude. However, I have never needed to do that so I cannot tell you the exact procedure.
If you can load on your work computer the drivers that the programmer needs, then you can of course take the GLCD to work and program it there.