├── Pi_Serial_FB_10.project ├── Example_SPS.ino └── README.md /Pi_Serial_FB_10.project: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pi4IoT/CODESYS_Serial/HEAD/Pi_Serial_FB_10.project -------------------------------------------------------------------------------- /Example_SPS.ino: -------------------------------------------------------------------------------- 1 | 2 | #include "High_Temp.h" 3 | #include 4 | 5 | Grove_LED_Bar bar(3, 2, 1); // Clock pin, Data pin, Orientation 6 | HighTemp ht(A1, A0); 7 | int Temp; 8 | char inChar; 9 | 10 | void setup() 11 | { 12 | Serial.begin(9600); 13 | ht.begin(); 14 | bar.begin(); 15 | } 16 | 17 | void loop() 18 | { 19 | if (Serial.available() > 0) { 20 | inChar = Serial.read(); 21 | if (inChar == 'g'){ 22 | Temp = ht.getThmc(); 23 | Serial.println(Temp); 24 | } 25 | if (isHexadecimalDigit(inChar)) { 26 | bar.setLevel(int(inChar)-48); 27 | //Serial.println(inChar); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CODESYS_Serial 2 | ## [YouTube Video](https://youtu.be/AeyhBszlmOY) 3 | ## CODESYS - Raspberry - Arduino – RS232(USB) 4 | 5 | ![RS232](https://user-images.githubusercontent.com/36192933/38459693-6970b904-3aad-11e8-9068-33f613c36dde.jpg) 6 |

7 | [Arduino Program](https://github.com/Pi4IoT/CODESYS_Serial/blob/master/Example_SPS.ino)
8 | [CODESYS Program](https://github.com/Pi4IoT/CODESYS_Serial/blob/master/Pi_Serial_FB_10.project) 9 |

10 | This example demonstrates how serial communication can be implemented, how ports are opened, 11 | closed on Raspberry Pi to communicate with Arduino via COM Port RS232 by using CODESYS. 12 | 13 | The Demo set the light of the LED bar and read out the temperature from the thermocouple. 14 | 15 | First of all you need to download the free The CODESYS Development System (you need to register) after install it, 16 | you need to download CODESYS Control for Raspberry Pi SL (free version runs for 2h and the you need it to restart) 17 | 18 | ## Links: 19 | [CODESYS Development System ](https://store.codesys.com/codesys-23.html)
20 | [CODESYS Control for Raspberry Pi SL](https://store.codesys.com/codesys-control-for-raspberry-pi-sl.html?___store=en) 21 | 22 | ## Important 23 | After install Codesys on Raspberry you need to edit the file “CODESYSControl.cfg” as following: 24 | sudo nano /etc/CODESYSControl.cfg 25 |
26 | [SysCom]
27 |
28 | Linux.Devicefile=/dev/ttyACM
29 | portnum := COM.SysCom.SYS_COMPORT1
30 |
31 |
32 | Save it and restart the codesys controller
33 | sudo /etc/init.d/codesyscontrol restart
34 | --------------------------------------------------------------------------------