I am working on a Power monitoring project in my college. I came across the Arduino Energy Shield as in the link
http://www.olimex.cl/product_info.php?products_id=797 http://www.olimex.cl/product_info.php?products_id=797 . In this page there are examples given with the necessary headers.
I am not working on Arduino board, but I use Intel Edison with Arduino Break out board.
When I tried to work I observed :
1. There was no LED or any such indicator on the shield glowing
2. The code compiled Successfully , but the output was not good.
Irrespective of the sensor status Output was -
0-1/0-1/(¿Ð¿ - 45:0-1:8(
Voltaje RMS [V]: 1435.71
Corriente RMS [A]: 140.608
Potencia Activa [W] (Acumulada en [J] por 0,1 seg : ) 0.00
Potencia Aparente [VA] (Acumulada en [J] por 0,1 seg : ) 0.00
Potencia Reactiva [var] (Acumulada en [J] por 0,1 seg : ) 0.00
Periodo de la senal de voltaje [ms]: 0
Frecuencia de la senal de voltaje [Hz]: inf
Tipo de Carga :
Factor de Potencia : 1.00
Since the docs available are not in english I am finding it bit difficult to go ahead. Before I proceed,
It was mentioned in the product page that it is supported by 'UNO' boards. Can I use Edison Instead?? If Edison cannot replace UNO then what are the other option I have with edison?
Thanks in advance
When you power the Edison with the Arduino Expansion Board you should be able to see the DS3 LED "on". How are you powering the board?
Are you able to upload the Blink sketch into the board?
Which image version do you have in your board?
If it is supported by 'UNO' boards, it means that the libraries were made for their architecture and libraries, as you now the Edison Module has a different architecture and uses different libraries, that's why you have to choose which board are you using in the Arduino IDE. In this case, you may need to modify the library and the code in order to make this work.
I have found that the issue is not with libraries, at least for now, as they are just Wire.h and SPI.h
I would like to split my issue into two parts as I2C and SPI.
1. About the I2C,
I have to bring down the default i2c clock frequency (fast mode : 400Khz) to std mode (100KHz ).
After looking at this https://software.intel.com/en-us/articles/exploring-air-quality-monitoring-using-intel-edison page , I tried the below command
# echo std > /sys/devices/pci0000:00/0000:00:09.1/i2c_dw_sysnode/mode
# cat /sys/devices/pci0000:00/0000:00:09.1/i2c_dw_sysnode/mode
But the frequency was still 400 KHz as observed using a CRO. Once I reboot the board ,
# cat /sys/devices/pci0000:00/0000:00:09.1/i2c_dw_sysnode/mode
So does it mean that the change i make in writing 'std' to the file has no effect?? How can I achieve a 'std' clock on Edison's i2c?
2. About the SPI,
The SPI initialization on arduino IDE goes as below:
There was no clock generated at all!
Following the link /message/269955 https://communities.intel.com/message/269955 on page 31, there is a list of steps to enter into linux as shown to enable the edison for SPI...
root@edison:~# echo 111 > /sys/class/gpio/export
-sh: echo: write error: Device or resource busy
I now tried to follow a piece of code as in this /message/271847 link
- import mraa
- spi = mraa.Spi(5)
- while True:
I shorted the MOSI and MISO of edison and found the data as expected. Though I dint find the frequency to be set as in line 3. It was around ~4MHz.
Why was there no clock with arduino code??How do I set it to 500KHz on arduino IDE?? If it is possible only using mraa.Spi , then how do I set the mode??
Thanks in Advance.
Update on the SPI Issue,
I flashed with latest yocto image. And on running the code below ,
3. spi = mraa.Spi(5) # what is this 5??
5. spi.mode(2) # Tried to set to mode 2, have no idea if this is correct but have been able to find changes in the signal partially
The result was,
(I) I could see a 500KHz signal.
(II) The clock was held HIGH in IDLE condition.
(III) The MOSI was never HIGH at IDLE condition. In all 4 modes, changing line 5 in above code, I found MOSI was LOW in IDLE condition. According to a figure in http://www.gammon.com.au/spi this page, the MOSI should be held HIGH in MODE 0 and MODE 2.
My Slave does not transmit the signal correctly. As mentioned earlier that the shield was for UNO board and the MOSI in it was at HIGH at IDLE condition. So I think the MODE setting on the EDISON board should solve the SPI problem.
Which image and pins are you using?
Have you tried to change the speed with mraa? Are you getting the same results?
Have you tried by following the steps in http://www.intel.com/content/dam/support/us/en/documents/edison/sb/edisonarduino_hg_331191007.pdf section 11.6 and then changing the speed?
The frequency in the Arduino IDE can be set by using SPI.setClockDivider(SPI_CLOCK_DIV32) all this information could be checked in the SPI.cpp and SPI.h from the Arduino IDE files. If you are using the Arduino IDE 1.6.6, this file is located in C:\Users\Yourself\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.2+1.0\libraries\SPI\src\S...
The message -sh: echo: write error: Device or resource busy is because the gpio is already exported you can check this in /sys/kernel/debug/gpio_debug
What is the result of running the commands opkg list-installed mraa and configure_edison --version?
Take a look at https://github.com/intel-iot-devkit/mraa/blob/master/api/mraa/spi.hpp mraa/spi.hpp at master · intel-iot-devkit/mraa · GitHub for more information about these modes.
Are you checking the signals with a logic analyzer or an oscilloscope? Is this the only problem you are having?
The output for the commands:
root@edison:~# opkg list-installed mraa
mraa - 0.9.0
root@edison:~# configure_edison --version
Update on SPI from Arduino :
I have tried SPI.setClockDivider() ,it seems to affect the frequency and mode in no way.
SPI.setClockDivider(SPI_CLOCK_DIV32)all above only gave a ~4MHz clock output.
I also tried SPI.setDataMode(), even this had no effect on the clock signal,
all above only produced what seemed to be Mode 0.
So the problem here is both getting the clock at 500Khz and setting mode2.
Update on mraa.spi :
And as i've stated the results in the 'UPDATE on SPI' in my previous message, I was successful in getting the Clock and desired frequency using mraa spi. I could also observe the different modes using spi.mode(x). The only problem was the signal on MOSI line not being HIGH in idle state , as it is supposed to be in mode 2.
Thank you for the reply. But I got the SPI working after I flashed with latest Image. Using your previous instructions I could get the frequency and mode set using ARDUINO IDE.
Also there is one small change to be made in spi initialization.
SPI.begin(); is to be done before setting up frequecy and mode. I accidentally figured it out when I was writing my test code.