[Resuelto] SPI and I2C  

  RSS

wowhunter
(@wowhunter)
New Member
Registrado: hace 2 años
Respuestas: 1
19/09/2017 2:01 am  

Can you give me some guidance on communicating with SPI and I2C interfaces using MyOpenLab on Raspberry PI please?


Citar
admin
(@admin)
Miembro Admin
Registrado: hace 2 años
Respuestas: 104
19/09/2017 9:13 pm  

Hi,

You can communicate with I2C or SPI with a simple "run once" python script...

Each time that you call the script It must return your data formated in string. 

You can do it and test it througt the linux or windows terminal, when you execute the script you could see the response of the module formated as you has programmed in the script...

There is a good example of something similar at: 

 https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/ads1015-slash-ads1115 

When you finish do this step you will be  able to call your script from MyOpenLab with the "CMD_Write_JV" element and It will get the terminal response, the you can format and show it in MyOpenLab Interface.

There is an example of the "CMD_Write_JV" located at: 

VirtualMachines > English Examples > Application_Control > cmdWrite_JV_Example

 

Best Regards,

Javier Velásquez

 


ResponderCitar
Loren
(@loren)
New Member
Registrado: hace 2 años
Respuestas: 1
07/04/2018 4:08 am  

Hi Javier

I'm trying to read a pH meter by using I2C protocol too. Could you give me some tips or  documents to programate this protocol in my openlab?
Thank you


ResponderCitar
admin
(@admin)
Miembro Admin
Registrado: hace 2 años
Respuestas: 104
07/04/2018 8:55 am  

Hi, 

The next distribution will include a element to use the I2C Raspberry PI port, but I am developing more front panel elements, Pipeline, tanks, valves, new boolean controls and Indicators, Temperature indicators, Gauge indicators and I am fixing bugs first.

Are you using Raspberry I2C Port? If Yes:

To do a VM that can communicate with I2C you can write your own Python Script and you can get the result with MyOpenLab trought the Linux Terminal with the "CMD_Write_JV" element.

Your Python Script should be "once time execution" and It should query the sensor and return the response. By Example you can see how works the Wiring PI Library, if you type in the Linux Terminal "digitalRead (int pin) " It returns an integer 0 or 1 depending of the pin status.

 http://wiringpi.com/reference/core-functions/ 

When you finish your Python script and you can execute it from terminal and get the response
you will be ready to implement it on MyOpenLab.

There is an example of the "CMD Write_JV" example located at:

\VirtualMachines\English Examples\Application_Control\cmdWrite_JV_Example

 

Best regards,

Javier Velásquez


ResponderCitar
Natanjimenez
(@natanjimenez)
New Member
Registrado: hace 8 meses
Respuestas: 3
16/02/2019 10:10 am  

ESta opcion solo ejecuta un comando en Linux?  intento poner varios comando pero me da error

cd direccion && script.py 

y me da error.


ResponderCitar
admin
(@admin)
Miembro Admin
Registrado: hace 2 años
Respuestas: 104
17/02/2019 10:49 pm  

Hola,

Envía a la terminal el comando que se ponga como entrada, si no lo ejecuta puede ser un error de la máquina de Java al enviar esos comandos múltiples, por el momento tocaría que llame directamente al script con la ruta fija y que el script sea el que ejecute toda la secuencia de comandos necesaria.

 

Saludos


ResponderCitar
Share: