{"id":2717,"date":"2024-10-01T09:53:08","date_gmt":"2024-10-01T08:53:08","guid":{"rendered":"https:\/\/www.robertprice.co.uk\/robblog\/?p=2717"},"modified":"2024-10-01T09:53:08","modified_gmt":"2024-10-01T08:53:08","slug":"connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/","title":{"rendered":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">With more devices than ever being Internet enabled, I wanted to look at linking up a Mendix application to a microcontroller and seeing if I could control it remotely. I decided to use a <a href=\"https:\/\/datasheets.raspberrypi.com\/picow\/pico-w-product-brief.pdf\">Raspberry Pi Pico W<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the Raspberry Pi Pico W?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Raspberry Pi Pico W is a microcontroller board that is an upgraded version of the original Raspberry Pi Pico, incorporating wireless capabilities, and <a href=\"https:\/\/thepihut.com\/products\/raspberry-pi-pico-w\">costing less than \u00a36<\/a>. Released in 2022, the Pico W is built around the RP2040 microcontroller, a custom-designed chip from Raspberry Pi. It features a dual-core Arm Cortex-M0+ processor running at up to 133 MHz, 264 KB of SRAM, and 2 MB of onboard flash memory. This powerful combination allows it to handle a wide range of tasks, from controlling sensors and actuators to performing moderate computational tasks like signal processing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of the key features that sets the Pico W apart from its predecessor is the inclusion of wireless connectivity, specifically Wi-Fi. It uses the Infineon CYW43439 chip to provide 2.4 GHz 802.11n wireless networking. This opens up new possibilities for IoT (Internet of Things) applications, where devices need to communicate with each other or with the cloud. The wireless capability makes it ideal for projects like home automation, remote sensing, and wireless data logging, where connectivity is crucial.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Despite its powerful capabilities, the Raspberry Pi Pico W remains highly affordable, maintaining the same low-cost philosophy as other Raspberry Pi products. Its compact size and efficient power usage also make it suitable for battery-powered or embedded projects. The board supports a variety of programming languages, including MicroPython, C\/C++, and CircuitPython, making it accessible to both beginners and experienced developers. Overall, the Raspberry Pi Pico W is a versatile, cost-effective solution for projects that require both local processing and wireless connectivity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Building a simple REST service <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, I\u2019m going to use MicroPython to create a REST service than my Mendix application can consume.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Raspberry Pi Pico W has a couple of built in features we can expose to our REST service. The first is the built in LED. We can add REST endpoints to turn this on and off. The second is the built in Analog to Digital Converter (ADC) that we can use to take a temperature reading. We can add a REST endpoint to return the current temperature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The easiest way to build a REST service on the Raspberry Pi Pico W that I have found is to use the Phew library. This allows us to define endpoints that run specific Python defs to return data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You will need to install an application called Thonny on your computer to be able to upload the MicroPython code to your Raspberry Pi Pico W. You can find full instructions on the Thonny website. <a href=\"https:\/\/thonny.org\/\">https:\/\/thonny.org\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This isn\u2019t a MicroPython tutorial, so I won\u2019t explain the code in depth. The main parts to look at are the endpoints and their return values. For example, I define the temperature I use the following line\u2026<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@server.route(\"\/api\/temperature\", methods=&#91;\"GET\"])<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This defines the endpoint to respond to GET requests to \/api\/temperature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The data is returned as JSON using the following line\u2026<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return json.dumps({\"temperature\" : temperature}), 200, {\"Content-Type\": \"application\/json\"}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">There are similar endpoints and return values to turn the LED on and off.<br><br>Here&#8217;s the code to upload to your Raspberry Pi Pico W if you are following along.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from phew import server, connect_to_wifi\nimport machine\nimport json\n\n# Connect to WIFI\nip = connect_to_wifi(\"YOUR-WIFI-NAME\", \"YOUR-WIFI-PASSWORD\")\n\n# Get the onboard LED\nled = machine.Pin(\"LED\", machine.Pin.OUT)\n\nprint(\"connected to IP \", ip)\n\n# Setup the temperature endpoint. \n@server.route(\"\/api\/temperature\", methods=&#91;\"GET\"])\ndef get_temperature(request):\n    adc = machine.ADC(4)  # Use ADC pin GP4\n    conversion_factor = 3.3 \/ (65535)  # ADC conversion factor\n    sensor_value = adc.read_u16() * conversion_factor\n    temperature = 27 - (sensor_value - 0.706) \/ 0.001721  # Convert sensor value to temperature (formula may vary)\n    \n    return json.dumps({\"temperature\" : temperature}), 200, {\"Content-Type\": \"application\/json\"}\n\n# Setup the LED ON endpoint.\n@server.route(\"\/api\/led\/on\", methods=&#91;\"GET\"])\ndef ledCommand(request):\n    led.value(1)\n    return json.dumps({\"message\" : \"Command sent successfully!\"}), 200, {\"Content-Type\": \"application\/json\"}\n\n# Setup the LED OFF endpoint.\n@server.route(\"\/api\/led\/off\", methods=&#91;\"GET\"])\ndef ledCommand(request):\n    led.value(0)\n    return json.dumps({\"message\" : \"Command sent successfully!\"}), 200, {\"Content-Type\": \"application\/json\"}\n\n# Setup a catchall for all other requests we can't handle.\n@server.catchall()\ndef catchall(request):\n    return json.dumps({\"message\" : \"URL not found!\"}), 404, {\"Content-Type\": \"application\/json\"}\n\n# Start the REST service.\nserver.run()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Upload and run this MicroPython program to your Raspberry Pi Pico W using Thonny. When you run it, it will connect to the specified Wifi network using the username and password you supplied in the code, and it will return an IP address that you can use in your Mendix application to talk to the Pico.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MPY: soft reboot\n2024-09-30 21:17:28 &#91;debug    \/ 163kB]   - connecting\n2024-09-30 21:17:31 &#91;debug    \/ 161kB]   - connecting\nconnected to IP  192.168.178.84\n2024-09-30 21:17:33 &#91;info     \/ 169kB] > starting web server on port 80<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can quickly test if everything is working by connecting to our REST service using a web browser. My Pico returned it was connected to 192.168.178.84 (your IP address may be different), so I can turn the LED on by going to http:\/\/192.168.178.84\/api\/led\/on . The LED will turn on, and the following JSON will have been returned.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\"message\": \"Command sent successfully!\"}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, lets write a Mendix application do this.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Building the Mendix application<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Firstly, create a new Mendix application. I\u2019ve called mine PicoWIOT.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mendix has a new feature called <a href=\"https:\/\/docs.mendix.com\/refguide\/consumed-rest-services-beta\/\">Consumed REST Services<\/a> which is currently in Beta. This makes it really easy to consume external web services. To use it, create a Consumed Web Service. I called mine CWS_PicoW.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice-1024x283.png\" alt=\"\" class=\"wp-image-2721\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice-1024x283.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice-300x83.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice-768x212.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice-1200x331.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-add-consumed-webservice.png 1304w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the Configuration and authentication tab, set the Base URL to be http:\/\/192.168.178.84\/api\/ . We don&#8217;t have any Authentication, so leave that as &#8220;No Authentication&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-editconfiguration.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1014\" height=\"534\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-editconfiguration.png\" alt=\"\" class=\"wp-image-2723\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-editconfiguration.png 1014w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-editconfiguration-300x158.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-editconfiguration-768x404.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To add the LED On endpoint, set the Request name to be \u201cLEDOn\u201d, the Method to be \u201cGET\u201d, and the URL to be \u201c\/led\/on\u201d. If you then click the Send button to test the request you should see the LED light up and the JSON data be returned. We can use this to create a response entity if we want.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"380\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-1024x380.png\" alt=\"\" class=\"wp-image-2727\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-1024x380.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-300x111.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-768x285.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-1536x570.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2-1200x445.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-ledon2.png 1612w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can add the LED Off endpoint by doing the same again, but this time changing the URL to be \u201c\/led\/off\u201d. Clicking Send this time will turn the LED off.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can add the Temperature endpoint by doing the same again, but this time changing the URL to be \u201c\/temperature\u201d. Clicking Send will now read the temperature and return it in the JSON response. We should create a new entity to store this by going into the Response Structure tab and clicking Create Entity. I called my entity \u201cRootTemperature\u201d.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"796\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-1024x796.png\" alt=\"\" class=\"wp-image-2735\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-1024x796.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-300x233.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-768x597.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-1536x1194.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2-1200x933.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-temperature2.png 1598w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need to be able to call these endpoints from our application. We do this using Mendix microflows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To turn the LED On, we can create a new microflow called ACT_LEDOn. Add an action, and look for <a href=\"https:\/\/docs.mendix.com\/refguide\/send-rest-request\/\">Send REST Request<\/a>. You should see the LEDOn call we created earlier, so select that. Finally make sure the microflow has a suitable User Role selected so it can be executed and save it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"447\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-1024x447.png\" alt=\"\" class=\"wp-image-2733\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-1024x447.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-300x131.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-768x335.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-1536x671.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon-1200x524.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-mf-ledon.png 1754w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do the same for LED Off.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On a page, drag the ACT_LEDOn microflow somewhere suitable to create a button, and also do the same for ACT_LEDOff. I renamed mine to LEDOn and LEDOff. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-1024x684.png\" alt=\"\" class=\"wp-image-2739\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-1024x684.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-300x200.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-768x513.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-1536x1025.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2-1200x801.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage2.png 1594w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now run the application and open it in your browser.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"938\" height=\"514\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage1.png\" alt=\"\" class=\"wp-image-2737\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage1.png 938w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage1-300x164.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-homepage1-768x421.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should get a page with the two buttons on. Pressing them should turn the LED on and off on the Raspberry Pi Pico W.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To read the temperature on the Pico, first create a new Page in Mendix called Temperature. I used a Popup layout. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"699\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-1024x699.png\" alt=\"\" class=\"wp-image-2741\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-1024x699.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-300x205.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-768x524.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-1536x1049.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature-1200x819.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature.png 1658w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add a DataView to the page, and use the RootTemperature entity we created earlier. Let it automatically populate the page for you. I removed the Save and Cancel buttons and replaced them with a single Close page button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"345\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-1024x345.png\" alt=\"\" class=\"wp-image-2743\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-1024x345.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-300x101.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-768x259.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-1536x517.png 1536w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2-1200x404.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature2.png 1586w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now create a new microflow called ACT_Temperature. Add a Send REST Request action, and call the Temperature endpoint. Use the Return Value, I called mine RootTemperature, and pass this as the parameter to a Show Page action that calls the Temperature Popup page we just created. Save the microflow, and remember to give it a suitable User Role. Drag the ACT_Temperature microflow onto the same page as the LED buttons to create a new button. I renamed mine to Temperature.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run the app, and you should have three buttons. Click Temperature and you should get a popup with the current temperature according to the ADC on your Raspberry Pi Pico W.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"677\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3-1024x677.png\" alt=\"\" class=\"wp-image-2747\" srcset=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3-1024x677.png 1024w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3-300x198.png 300w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3-768x508.png 768w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3-1200x794.png 1200w, https:\/\/www.robertprice.co.uk\/robblog\/assets\/pico-page-temperature3.png 1388w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations, you have successfully integrated Mendix with your very own Internet of Things (IoT) device!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hopefully this article has shown how easy it is for a modern low code application to interact with a cheap microcontroller so it can interact with sensors and output devices.<br><br>We&#8217;ve also seen how to easy it is to integrate REST services with Mendix using the new Consumed REST Service functionality.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With more devices than ever being Internet enabled, I wanted to look at linking up a Mendix application to a microcontroller and seeing if I could control it remotely. I decided to use a Raspberry Pi Pico W. What is the Raspberry Pi Pico W? The Raspberry Pi Pico W is a microcontroller board that &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Connecting Mendix To A Raspberry Pi Pico W Microcontroller&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2765,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[121],"tags":[125,98,127,123,129],"class_list":["post-2717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mendix","tag-iot","tag-mendix","tag-microcontroller","tag-raspberry-pi-pico-w","tag-rest"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price<\/title>\n<meta name=\"description\" content=\"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price\" \/>\n<meta property=\"og:description\" content=\"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-01T08:53:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"480\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Connecting Mendix To A Raspberry Pi Pico W Microcontroller\",\"datePublished\":\"2024-10-01T08:53:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/\"},\"wordCount\":1299,\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/raspberry-pi-pico-w-clean.jpg\",\"keywords\":[\"IoT\",\"Mendix\",\"Microcontroller\",\"Raspberry Pi Pico W\",\"REST\"],\"articleSection\":[\"Mendix\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/\",\"name\":\"Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/raspberry-pi-pico-w-clean.jpg\",\"datePublished\":\"2024-10-01T08:53:08+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"description\":\"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/raspberry-pi-pico-w-clean.jpg\",\"contentUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/raspberry-pi-pico-w-clean.jpg\",\"width\":800,\"height\":480,\"caption\":\"Raspberry Pi Pico W\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Connecting Mendix To A Raspberry Pi Pico W Microcontroller\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price","description":"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/","og_locale":"en_GB","og_type":"article","og_title":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price","og_description":"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/","og_site_name":"Robert Price","article_published_time":"2024-10-01T08:53:08+00:00","og_image":[{"width":800,"height":480,"url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg","type":"image\/jpeg"}],"author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller","datePublished":"2024-10-01T08:53:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/"},"wordCount":1299,"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg","keywords":["IoT","Mendix","Microcontroller","Raspberry Pi Pico W","REST"],"articleSection":["Mendix"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/","name":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#primaryimage"},"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg","datePublished":"2024-10-01T08:53:08+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"description":"We explore how to link a Mendix application to a Raspberry Pi Pico W microcontroller to turn LEDs on and off, and to read the current temperature.","breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#primaryimage","url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg","contentUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/raspberry-pi-pico-w-clean.jpg","width":800,"height":480,"caption":"Raspberry Pi Pico W"},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/connecting-mendix-to-a-raspberry-pi-pico-w-microcontroller\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Connecting Mendix To A Raspberry Pi Pico W Microcontroller"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=2717"}],"version-history":[{"count":10,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2717\/revisions"}],"predecessor-version":[{"id":2763,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/2717\/revisions\/2763"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media\/2765"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=2717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=2717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=2717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}